Spaces:
Sleeping
Sleeping
added calculator
Browse files
app.py
CHANGED
@@ -75,6 +75,20 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
75 |
except Exception as e:
|
76 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
final_answer = FinalAnswerTool()
|
80 |
|
@@ -97,7 +111,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
97 |
|
98 |
agent = CodeAgent(
|
99 |
model=model,
|
100 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
101 |
max_steps=6,
|
102 |
verbosity_level=1,
|
103 |
grammar=None,
|
|
|
75 |
except Exception as e:
|
76 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
77 |
|
78 |
+
@tool
|
79 |
+
def calculator_tool(expression: str) -> str:
|
80 |
+
"""
|
81 |
+
A tool that evaluates a basic arithmetic expression using a safe calculator function.
|
82 |
+
|
83 |
+
Args:
|
84 |
+
expression: A string containing a basic arithmetic expression (e.g., "2+2", "3*4").
|
85 |
+
|
86 |
+
Returns:
|
87 |
+
The result of evaluating the expression as a string.
|
88 |
+
"""
|
89 |
+
from Gradio_UI import calculator # ADDED: Import the safe calculator function
|
90 |
+
return calculator(expression)
|
91 |
+
|
92 |
|
93 |
final_answer = FinalAnswerTool()
|
94 |
|
|
|
111 |
|
112 |
agent = CodeAgent(
|
113 |
model=model,
|
114 |
+
tools=[final_answer, wikipedia_search, calculator_tool], ## add your tools here (don't remove final answer)
|
115 |
max_steps=6,
|
116 |
verbosity_level=1,
|
117 |
grammar=None,
|