Coool2 commited on
Commit
e1fe6bb
·
verified ·
1 Parent(s): 3c271e0

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +6 -19
agent.py CHANGED
@@ -468,39 +468,26 @@ class EnhancedGAIAAgent:
468
 
469
  Instructions:
470
  1. Analyze this GAIA question using ReAct reasoning
471
- 2. Use specialist agents ONLY when their specific expertise is needed
472
  3. Provide a precise, exact answer in GAIA format
473
 
474
  Begin your reasoning process:
475
  """
476
 
477
  try:
478
- # Utiliser la méthode correcte pour ReActAgent
479
  import asyncio
480
-
481
- # Créer un contexte pour le workflow
482
  from llama_index.core.workflow import Context
 
 
483
  ctx = Context(self.coordinator)
484
 
485
- # Exécuter le workflow de manière asynchrone
486
  async def run_agent():
487
  response = await self.coordinator.run(ctx=ctx, input=context_prompt)
488
  return response
489
 
490
- # Exécuter dans une boucle d'événements
491
- try:
492
- loop = asyncio.get_event_loop()
493
- if loop.is_running():
494
- # Si on est déjà dans une boucle async (comme dans Gradio)
495
- import nest_asyncio
496
- nest_asyncio.apply()
497
- response = loop.run_until_complete(run_agent())
498
- else:
499
- response = asyncio.run(run_agent())
500
- except RuntimeError:
501
- # Fallback pour les environnements où asyncio pose problème
502
- response = asyncio.run(run_agent())
503
-
504
  return str(response)
505
 
506
  except Exception as e:
 
468
 
469
  Instructions:
470
  1. Analyze this GAIA question using ReAct reasoning
471
+ 2. Use specialist tools ONLY when their specific expertise is needed
472
  3. Provide a precise, exact answer in GAIA format
473
 
474
  Begin your reasoning process:
475
  """
476
 
477
  try:
 
478
  import asyncio
 
 
479
  from llama_index.core.workflow import Context
480
+
481
+ # Créer le contexte
482
  ctx = Context(self.coordinator)
483
 
484
+ # Fonction asynchrone pour exécuter l'agent
485
  async def run_agent():
486
  response = await self.coordinator.run(ctx=ctx, input=context_prompt)
487
  return response
488
 
489
+ # Exécuter de manière asynchrone
490
+ response = asyncio.run(run_agent())
 
 
 
 
 
 
 
 
 
 
 
 
491
  return str(response)
492
 
493
  except Exception as e: