Spaces:
Sleeping
Sleeping
Priyanshi Saxena
commited on
Commit
Β·
0d94513
1
Parent(s):
fb7643a
fix: Resolve config attribute error and chart_data_tool parameter handling
Browse files- Fix 'Web3ResearchAgent' object has no attribute 'config' error
- Change self.config.OLLAMA_MODEL to config.OLLAMA_MODEL in metadata
- Add proper parameter handling for chart_data_provider tool
- Extract chart_type and symbol from query for structured tool calls
- Prevent chart_data_tool from receiving raw query strings
Resolves:
- AttributeError: 'Web3ResearchAgent' object has no attribute 'config'
- chart_data_provider error: 'Unknown chart type: Analyze Bitcoin...'
- Proper tool parameter extraction and execution
- src/agent/research_agent.py +26 -2
src/agent/research_agent.py
CHANGED
|
@@ -242,7 +242,31 @@ Just list the tool names:"""
|
|
| 242 |
if tool:
|
| 243 |
try:
|
| 244 |
logger.info(f"π§ Executing {tool_name}")
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
logger.info(f"π {tool_name} result preview: {str(result)[:200]}...")
|
| 247 |
tool_results.append(f"=== {tool_name} Results ===\n{result}\n")
|
| 248 |
except Exception as e:
|
|
@@ -308,7 +332,7 @@ The system successfully gathered data from {len(suggested_tools)} tools:
|
|
| 308 |
"result": final_response,
|
| 309 |
"sources": [],
|
| 310 |
"metadata": {
|
| 311 |
-
"llm_used": f"Ollama ({
|
| 312 |
"tools_used": suggested_tools,
|
| 313 |
"timestamp": datetime.now().isoformat()
|
| 314 |
}
|
|
|
|
| 242 |
if tool:
|
| 243 |
try:
|
| 244 |
logger.info(f"π§ Executing {tool_name}")
|
| 245 |
+
|
| 246 |
+
# Handle chart_data_provider with proper parameters
|
| 247 |
+
if tool_name == "chart_data_provider":
|
| 248 |
+
# Extract chart type from query or default to price_chart
|
| 249 |
+
chart_type = "price_chart" # Default
|
| 250 |
+
symbol = "bitcoin" # Default
|
| 251 |
+
|
| 252 |
+
if "defi" in query.lower() or "tvl" in query.lower():
|
| 253 |
+
chart_type = "defi_tvl"
|
| 254 |
+
elif "market" in query.lower() or "overview" in query.lower():
|
| 255 |
+
chart_type = "market_overview"
|
| 256 |
+
elif "gas" in query.lower():
|
| 257 |
+
chart_type = "gas_tracker"
|
| 258 |
+
|
| 259 |
+
# Extract symbol if mentioned
|
| 260 |
+
if "ethereum" in query.lower() or "eth" in query.lower():
|
| 261 |
+
symbol = "ethereum"
|
| 262 |
+
elif "bitcoin" in query.lower() or "btc" in query.lower():
|
| 263 |
+
symbol = "bitcoin"
|
| 264 |
+
|
| 265 |
+
result = await tool._arun(chart_type=chart_type, symbol=symbol)
|
| 266 |
+
else:
|
| 267 |
+
# Other tools use the query directly
|
| 268 |
+
result = await tool._arun(query)
|
| 269 |
+
|
| 270 |
logger.info(f"π {tool_name} result preview: {str(result)[:200]}...")
|
| 271 |
tool_results.append(f"=== {tool_name} Results ===\n{result}\n")
|
| 272 |
except Exception as e:
|
|
|
|
| 332 |
"result": final_response,
|
| 333 |
"sources": [],
|
| 334 |
"metadata": {
|
| 335 |
+
"llm_used": f"Ollama ({config.OLLAMA_MODEL})",
|
| 336 |
"tools_used": suggested_tools,
|
| 337 |
"timestamp": datetime.now().isoformat()
|
| 338 |
}
|