Spaces:
Sleeping
Sleeping
tool
Browse files
agent.py
CHANGED
@@ -16,7 +16,11 @@ from tools import (
|
|
16 |
audio_transcriber_tool,
|
17 |
excel_tool,
|
18 |
analyze_code_tool,
|
19 |
-
image_tool
|
|
|
|
|
|
|
|
|
20 |
)
|
21 |
|
22 |
# βββββββββββββββββββββββββββ Configuration βββββββββββββββββββββββββββββββ
|
@@ -43,7 +47,11 @@ def build_graph():
|
|
43 |
audio_transcriber_tool,
|
44 |
excel_tool,
|
45 |
analyze_code_tool,
|
46 |
-
image_tool
|
|
|
|
|
|
|
|
|
47 |
]
|
48 |
|
49 |
# Create the react agent - it will use the system prompt from the messages
|
|
|
16 |
audio_transcriber_tool,
|
17 |
excel_tool,
|
18 |
analyze_code_tool,
|
19 |
+
image_tool,
|
20 |
+
add_tool,
|
21 |
+
subtract_tool,
|
22 |
+
multiply_tool,
|
23 |
+
divide_tool
|
24 |
)
|
25 |
|
26 |
# βββββββββββββββββββββββββββ Configuration βββββββββββββββββββββββββββββββ
|
|
|
47 |
audio_transcriber_tool,
|
48 |
excel_tool,
|
49 |
analyze_code_tool,
|
50 |
+
image_tool,
|
51 |
+
add_tool,
|
52 |
+
subtract_tool,
|
53 |
+
multiply_tool,
|
54 |
+
divide_tool
|
55 |
]
|
56 |
|
57 |
# Create the react agent - it will use the system prompt from the messages
|
app.py
CHANGED
@@ -44,8 +44,8 @@ class BasicAgent:
|
|
44 |
]
|
45 |
}
|
46 |
|
47 |
-
# Run the agent
|
48 |
-
out_state = self.graph.invoke(init_state, {"recursion_limit":
|
49 |
|
50 |
# Extract the final answer from the last message
|
51 |
if out_state and "messages" in out_state:
|
|
|
44 |
]
|
45 |
}
|
46 |
|
47 |
+
# Run the agent with increased steps
|
48 |
+
out_state = self.graph.invoke(init_state, {"recursion_limit": 15})
|
49 |
|
50 |
# Extract the final answer from the last message
|
51 |
if out_state and "messages" in out_state:
|
tools.py
CHANGED
@@ -405,3 +405,55 @@ def analyze_code_tool(task_id: str) -> str:
|
|
405 |
# "web_search_query": None,
|
406 |
# "web_search_result": result_text
|
407 |
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
# "web_search_query": None,
|
406 |
# "web_search_result": result_text
|
407 |
# }
|
408 |
+
|
409 |
+
# βββββββββββββββββββββββββββ Math Tools βββββββββββββββββββββββββββββββ
|
410 |
+
|
411 |
+
@tool
|
412 |
+
def add_tool(a: float, b: float) -> str:
|
413 |
+
"""
|
414 |
+
Add two numbers.
|
415 |
+
Args:
|
416 |
+
a: First number
|
417 |
+
b: Second number
|
418 |
+
Returns: The sum of a and b
|
419 |
+
"""
|
420 |
+
result = a + b
|
421 |
+
return f"Addition result: {a} + {b} = {result}"
|
422 |
+
|
423 |
+
@tool
|
424 |
+
def subtract_tool(a: float, b: float) -> str:
|
425 |
+
"""
|
426 |
+
Subtract two numbers.
|
427 |
+
Args:
|
428 |
+
a: First number (minuend)
|
429 |
+
b: Second number (subtrahend)
|
430 |
+
Returns: The difference of a minus b
|
431 |
+
"""
|
432 |
+
result = a - b
|
433 |
+
return f"Subtraction result: {a} - {b} = {result}"
|
434 |
+
|
435 |
+
@tool
|
436 |
+
def multiply_tool(a: float, b: float) -> str:
|
437 |
+
"""
|
438 |
+
Multiply two numbers.
|
439 |
+
Args:
|
440 |
+
a: First number
|
441 |
+
b: Second number
|
442 |
+
Returns: The product of a and b
|
443 |
+
"""
|
444 |
+
result = a * b
|
445 |
+
return f"Multiplication result: {a} Γ {b} = {result}"
|
446 |
+
|
447 |
+
@tool
|
448 |
+
def divide_tool(a: float, b: float) -> str:
|
449 |
+
"""
|
450 |
+
Divide two numbers.
|
451 |
+
Args:
|
452 |
+
a: First number (dividend)
|
453 |
+
b: Second number (divisor)
|
454 |
+
Returns: The quotient of a divided by b
|
455 |
+
"""
|
456 |
+
if b == 0:
|
457 |
+
return "Division error: Cannot divide by zero"
|
458 |
+
result = a / b
|
459 |
+
return f"Division result: {a} Γ· {b} = {result}"
|