Coool2 commited on
Commit
77eaebf
·
verified ·
1 Parent(s): f2f7433

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +41 -34
agent.py CHANGED
@@ -402,61 +402,68 @@ code_agent = ReActAgent(
402
 
403
  class EnhancedGAIAAgent:
404
  def __init__(self):
405
- self.router = TaskRouter()
406
 
407
- # Main ReActAgent that coordinates everything
408
- self.main_agent = ReActAgent(
409
- name="MainGAIAAgent",
410
- description="Main GAIA agent that coordinates research, analysis, and computation to solve complex questions",
 
 
 
 
 
411
  system_prompt="""
412
- You are the main GAIA agent coordinator using ReAct reasoning methodology.
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
435
  ]
436
  )
 
437
 
438
- async def solve_gaia_question(self, question_data: Dict[str, Any]) -> str:
439
  question = question_data.get("Question", "")
440
  task_id = question_data.get("task_id", "")
441
 
442
- # Prepare comprehensive context
443
  context_prompt = f"""
444
  GAIA Task ID: {task_id}
445
  Question: {question}
446
 
447
- {'Associated files: ' + question_data.get('file_name', '') if 'file_name' in question_data else 'No files provided'}
448
 
449
  Instructions:
450
- 1. Analyze this GAIA question carefully using ReAct reasoning
451
- 2. Determine what information, analysis, or calculations are needed
452
- 3. Use appropriate tools to gather information and perform analysis
453
- 4. Synthesize findings into a precise, exact answer
454
- 5. Ensure your answer format matches GAIA requirements (exact, concise)
455
 
456
- Begin your ReAct reasoning process now.
457
  """
458
 
459
- # Execute main agent
460
- response = self.main_agent.chat(context_prompt)
461
-
462
- return str(response)
 
 
402
 
403
  class EnhancedGAIAAgent:
404
  def __init__(self):
405
+ print("Initializing Enhanced GAIA Agent...")
406
 
407
+ # Vérification du token HuggingFace
408
+ hf_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
409
+ if not hf_token:
410
+ raise ValueError("HUGGINGFACEHUB_API_TOKEN environment variable is required")
411
+
412
+ # Agent coordinateur principal qui utilise les agents spécialisés comme tools
413
+ self.coordinator = ReActAgent(
414
+ name="GAIACoordinator",
415
+ description="Main GAIA coordinator that uses specialist agents as intelligent tools",
416
  system_prompt="""
417
+ You are the main GAIA coordinator using ReAct reasoning methodology.
418
 
419
  Your process:
420
+ 1. THINK: Analyze the GAIA question thoroughly
421
+ - What type of information is needed?
422
+ - Are there files to analyze?
423
+ - Do I need research, analysis, or calculations?
424
+
425
+ 2. ACT: Use your specialist agents IF RELEVANT
426
+ - AnalysisAgent: ONLY for documents, images, files, or multimodal content
427
+ - ResearchAgent: ONLY for web search, scientific papers, factual information
428
+ - CodeAgent: ONLY for calculations, data processing, mathematical operations
429
 
430
+ 3. OBSERVE: Review results from specialist agents
431
+ 4. THINK: Determine if you need more information or can provide final answer
432
+ 5. ACT: Either use another agent or provide final precise answer
 
 
433
 
434
+ IMPORTANT: Use agents strategically - only when their specific expertise is needed.
435
+ For simple questions, you can answer directly without using any agents.
436
+ Always provide EXACT, CONCISE answers as required by GAIA format.
437
  """,
438
  llm=text_llm,
439
  tools=[
440
+ analysis_agent, # Agent spécialisé comme tool
441
+ research_agent, # Agent spécialisé comme tool
442
+ code_agent # Agent spécialisé comme tool
 
443
  ]
444
  )
445
+ print("Coordinator agent initialized")
446
 
447
+ def solve_gaia_question(self, question_data: Dict[str, Any]) -> str:
448
  question = question_data.get("Question", "")
449
  task_id = question_data.get("task_id", "")
450
 
 
451
  context_prompt = f"""
452
  GAIA Task ID: {task_id}
453
  Question: {question}
454
 
455
+ {f"Associated files: {question_data.get('file_name', '')}" if 'file_name' in question_data else 'No files provided'}
456
 
457
  Instructions:
458
+ 1. Analyze this GAIA question using ReAct reasoning
459
+ 2. Use specialist agents ONLY when their specific expertise is needed
460
+ 3. Provide a precise, exact answer in GAIA format
 
 
461
 
462
+ Begin your reasoning process:
463
  """
464
 
465
+ try:
466
+ response = self.coordinator.chat(context_prompt)
467
+ return str(response)
468
+ except Exception as e:
469
+ return f"Error processing question: {str(e)}"