Update agent.py
Browse files
agent.py
CHANGED
@@ -400,34 +400,6 @@ code_agent = ReActAgent(
|
|
400 |
can_handoff_to=["ResearchAgent", "AnalysisAgent"]
|
401 |
)
|
402 |
|
403 |
-
class TaskRouter:
|
404 |
-
def __init__(self):
|
405 |
-
self.agents = {
|
406 |
-
"AnalysisAgent": analysis_agent,
|
407 |
-
"ResearchAgent": research_agent,
|
408 |
-
"CodeAgent": code_agent
|
409 |
-
}
|
410 |
-
|
411 |
-
def route_task(self, question_data: Dict[str, Any]) -> str:
|
412 |
-
question = question_data.get("Question", "").lower()
|
413 |
-
has_files = "file_name" in question_data
|
414 |
-
|
415 |
-
# Routing logic
|
416 |
-
if has_files:
|
417 |
-
if any(keyword in question for keyword in ["image", "chart", "graph", "picture", "pdf", "document", "csv"]):
|
418 |
-
return "AnalysisAgent"
|
419 |
-
|
420 |
-
if any(keyword in question for keyword in ["calculate", "compute", "math", "number", "formula"]):
|
421 |
-
return "CodeAgent"
|
422 |
-
|
423 |
-
if any(keyword in question for keyword in ["search", "find", "who", "what", "when", "where", "research"]):
|
424 |
-
return "ResearchAgent"
|
425 |
-
|
426 |
-
return "AnalysisAgent" # Default
|
427 |
-
|
428 |
-
def get_agent(self, agent_name: str):
|
429 |
-
return self.agents.get(agent_name, self.agents["AnalysisAgent"])
|
430 |
-
|
431 |
class EnhancedGAIAAgent:
|
432 |
def __init__(self):
|
433 |
self.router = TaskRouter()
|
@@ -441,21 +413,22 @@ class EnhancedGAIAAgent:
|
|
441 |
|
442 |
Your process:
|
443 |
1. THINK: Analyze the GAIA question and determine what information/analysis is needed
|
444 |
-
2. ACT:
|
445 |
-
3. OBSERVE: Review the results from
|
446 |
4. THINK: Determine if you have enough information for a final answer
|
447 |
-
5. ACT: Either
|
448 |
|
449 |
-
Available
|
450 |
-
-
|
451 |
-
-
|
452 |
-
-
|
|
|
453 |
|
454 |
Always provide precise, exact answers as required by GAIA format.
|
455 |
""",
|
456 |
llm=text_llm,
|
457 |
tools=[
|
458 |
-
enhanced_research_tool_func,
|
459 |
enhanced_rag_tool,
|
460 |
cross_document_tool,
|
461 |
code_execution_tool
|
@@ -486,4 +459,4 @@ class EnhancedGAIAAgent:
|
|
486 |
# Execute main agent
|
487 |
response = self.main_agent.chat(context_prompt)
|
488 |
|
489 |
-
return str(response)
|
|
|
400 |
can_handoff_to=["ResearchAgent", "AnalysisAgent"]
|
401 |
)
|
402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
class EnhancedGAIAAgent:
|
404 |
def __init__(self):
|
405 |
self.router = TaskRouter()
|
|
|
413 |
|
414 |
Your process:
|
415 |
1. THINK: Analyze the GAIA question and determine what information/analysis is needed
|
416 |
+
2. ACT: Use appropriate tools to gather information and perform analysis
|
417 |
+
3. OBSERVE: Review the results from tools
|
418 |
4. THINK: Determine if you have enough information for a final answer
|
419 |
+
5. ACT: Either gather more information or provide the final answer
|
420 |
|
421 |
+
Available tools:
|
422 |
+
- Enhanced Research Tool: For ArXiv scientific research and web search with content extraction
|
423 |
+
- Enhanced RAG Analysis: For document/image analysis using advanced RAG
|
424 |
+
- Cross-Document Analysis: For multi-document reasoning and synthesis
|
425 |
+
- Python Code Execution: For calculations and data processing
|
426 |
|
427 |
Always provide precise, exact answers as required by GAIA format.
|
428 |
""",
|
429 |
llm=text_llm,
|
430 |
tools=[
|
431 |
+
enhanced_research_tool_func, # ✅ Fixed - use the correct variable name
|
432 |
enhanced_rag_tool,
|
433 |
cross_document_tool,
|
434 |
code_execution_tool
|
|
|
459 |
# Execute main agent
|
460 |
response = self.main_agent.chat(context_prompt)
|
461 |
|
462 |
+
return str(response)
|