Spaces:
Runtime error
Runtime error
Scott Cogan commited on
Commit ·
e56e6b6
1
Parent(s): c75b49f
fix: ensure all tools are proper Tool instances with required attributes
Browse files
app.py
CHANGED
|
@@ -191,17 +191,24 @@ class GetCurrentTimeInTimezoneTool(Tool):
|
|
| 191 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 192 |
|
| 193 |
# Create the agent with the templates
|
| 194 |
-
tools =
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
agent = CodeAgent(
|
| 203 |
model=model,
|
| 204 |
-
tools=tools, # Pass tools as a
|
| 205 |
max_steps=15,
|
| 206 |
verbosity_level=2,
|
| 207 |
grammar=None,
|
|
|
|
| 191 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 192 |
|
| 193 |
# Create the agent with the templates
|
| 194 |
+
tools = [
|
| 195 |
+
final_answer, # This is already a Tool instance
|
| 196 |
+
DuckDuckGoSearchTool(), # This is already a Tool instance
|
| 197 |
+
CalculateMinPriceTool(), # This is a Tool subclass
|
| 198 |
+
ExtractPriceFromSnippetTool(), # This is a Tool subclass
|
| 199 |
+
GetCurrentTimeInTimezoneTool() # This is a Tool subclass
|
| 200 |
+
]
|
| 201 |
+
|
| 202 |
+
# Verify all tools are proper Tool instances and have required attributes
|
| 203 |
+
for tool in tools:
|
| 204 |
+
if not isinstance(tool, Tool):
|
| 205 |
+
raise TypeError(f"Tool {tool} is not an instance of Tool or its subclass")
|
| 206 |
+
if not hasattr(tool, 'name') or not hasattr(tool, 'description'):
|
| 207 |
+
raise AttributeError(f"Tool {tool} is missing required attributes (name or description)")
|
| 208 |
|
| 209 |
agent = CodeAgent(
|
| 210 |
model=model,
|
| 211 |
+
tools=tools, # Pass tools as a list of Tool instances
|
| 212 |
max_steps=15,
|
| 213 |
verbosity_level=2,
|
| 214 |
grammar=None,
|