Spaces:
Runtime error
Runtime error
Scott Cogan
commited on
Commit
·
2c41210
1
Parent(s):
c09aeb1
fix: pass tools as list to match CodeAgent requirements
Browse files
app.py
CHANGED
|
@@ -198,18 +198,18 @@ class GetCurrentTimeInTimezoneTool(Tool):
|
|
| 198 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 199 |
|
| 200 |
# Create the agent with the templates
|
| 201 |
-
tools =
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
|
| 209 |
# Debug prints to inspect tools
|
| 210 |
-
logger.debug("Inspecting tools
|
| 211 |
-
for
|
| 212 |
-
logger.debug(f"Tool {
|
| 213 |
logger.debug(f" Type: {type(tool)}")
|
| 214 |
logger.debug(f" Is Tool instance: {isinstance(tool, Tool)}")
|
| 215 |
logger.debug(f" Has name: {hasattr(tool, 'name')}")
|
|
@@ -220,15 +220,21 @@ for name, tool in tools.items():
|
|
| 220 |
logger.debug(f" Description: {tool.description}")
|
| 221 |
|
| 222 |
# Verify all tools are proper Tool instances and have required attributes
|
| 223 |
-
for
|
| 224 |
if not isinstance(tool, Tool):
|
| 225 |
-
raise TypeError(f"Tool {
|
| 226 |
if not hasattr(tool, 'name') or not hasattr(tool, 'description'):
|
| 227 |
-
raise AttributeError(f"Tool {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
|
| 229 |
agent = CodeAgent(
|
| 230 |
model=model,
|
| 231 |
-
tools=tools, # Pass tools as a
|
| 232 |
max_steps=15,
|
| 233 |
verbosity_level=2,
|
| 234 |
grammar=None,
|
|
|
|
| 198 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 199 |
|
| 200 |
# Create the agent with the templates
|
| 201 |
+
tools = [
|
| 202 |
+
final_answer, # This is already a Tool instance
|
| 203 |
+
DuckDuckGoSearchTool(), # This is already a Tool instance
|
| 204 |
+
CalculateMinPriceTool(), # This is a Tool subclass
|
| 205 |
+
ExtractPriceFromSnippetTool(), # This is a Tool subclass
|
| 206 |
+
GetCurrentTimeInTimezoneTool() # This is a Tool subclass
|
| 207 |
+
]
|
| 208 |
|
| 209 |
# Debug prints to inspect tools
|
| 210 |
+
logger.debug("Inspecting tools list:")
|
| 211 |
+
for i, tool in enumerate(tools):
|
| 212 |
+
logger.debug(f"Tool {i}: {tool}")
|
| 213 |
logger.debug(f" Type: {type(tool)}")
|
| 214 |
logger.debug(f" Is Tool instance: {isinstance(tool, Tool)}")
|
| 215 |
logger.debug(f" Has name: {hasattr(tool, 'name')}")
|
|
|
|
| 220 |
logger.debug(f" Description: {tool.description}")
|
| 221 |
|
| 222 |
# Verify all tools are proper Tool instances and have required attributes
|
| 223 |
+
for tool in tools:
|
| 224 |
if not isinstance(tool, Tool):
|
| 225 |
+
raise TypeError(f"Tool {tool} is not an instance of Tool or its subclass")
|
| 226 |
if not hasattr(tool, 'name') or not hasattr(tool, 'description'):
|
| 227 |
+
raise AttributeError(f"Tool {tool} is missing required attributes (name or description)")
|
| 228 |
+
|
| 229 |
+
# Create a dictionary of tools for template rendering
|
| 230 |
+
tools_dict = {tool.name: tool for tool in tools}
|
| 231 |
+
logger.debug("Created tools dictionary:")
|
| 232 |
+
for name, tool in tools_dict.items():
|
| 233 |
+
logger.debug(f" {name}: {tool}")
|
| 234 |
|
| 235 |
agent = CodeAgent(
|
| 236 |
model=model,
|
| 237 |
+
tools=tools, # Pass tools as a list of Tool instances
|
| 238 |
max_steps=15,
|
| 239 |
verbosity_level=2,
|
| 240 |
grammar=None,
|