Denis Davydov
commited on
Commit
·
31ed54e
1
Parent(s):
c80da8b
remove calculator tool
Browse files
tools.py
CHANGED
@@ -166,26 +166,6 @@ image_analysis_tool = Tool(
|
|
166 |
description="Analyzes images to extract information. Use this for questions involving visual content."
|
167 |
)
|
168 |
|
169 |
-
def calculator_tool_func(expression: str) -> str:
|
170 |
-
"""Performs mathematical calculations safely."""
|
171 |
-
try:
|
172 |
-
# Basic safety check - only allow certain characters
|
173 |
-
allowed_chars = set('0123456789+-*/().= ')
|
174 |
-
if not all(c in allowed_chars for c in expression):
|
175 |
-
return f"Invalid characters in expression: {expression}"
|
176 |
-
|
177 |
-
# Use eval safely for basic math
|
178 |
-
result = eval(expression)
|
179 |
-
return f"Calculation result: {expression} = {result}"
|
180 |
-
except Exception as e:
|
181 |
-
return f"Calculation failed for '{expression}': {str(e)}"
|
182 |
-
|
183 |
-
calculator_tool = Tool(
|
184 |
-
name="calculator",
|
185 |
-
func=calculator_tool_func,
|
186 |
-
description="Performs mathematical calculations. Use this for numerical computations and math problems."
|
187 |
-
)
|
188 |
-
|
189 |
def text_processor_tool_func(text: str, operation: str = "summarize") -> str:
|
190 |
"""Processes text for various operations like summarization, extraction, etc."""
|
191 |
try:
|
@@ -385,6 +365,5 @@ agent_tools = [
|
|
385 |
web_search_tool,
|
386 |
file_download_tool,
|
387 |
image_analysis_tool,
|
388 |
-
calculator_tool,
|
389 |
text_processor_tool
|
390 |
]
|
|
|
166 |
description="Analyzes images to extract information. Use this for questions involving visual content."
|
167 |
)
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
def text_processor_tool_func(text: str, operation: str = "summarize") -> str:
|
170 |
"""Processes text for various operations like summarization, extraction, etc."""
|
171 |
try:
|
|
|
365 |
web_search_tool,
|
366 |
file_download_tool,
|
367 |
image_analysis_tool,
|
|
|
368 |
text_processor_tool
|
369 |
]
|