File size: 2,030 Bytes
407e466 953a28e c9d63bb e378548 953a28e 407e466 953a28e 407e466 57e2365 407e466 953a28e 57e2365 953a28e 57e2365 e378548 407e466 57e2365 e378548 f30003b 6e9fb70 e378548 6e9fb70 407e466 57e2365 e378548 407e466 953a28e 407e466 953a28e 407e466 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | """Agent wrapper module for GAIA Benchmark."""
import config
# All agents are imported lazily to avoid loading unnecessary dependencies
# and suppress warnings from unused agent implementations
class MyGAIAAgents:
"""Wrapper class to manage multiple agent implementations.
This class provides a unified interface for different agent types.
The active agent is determined by the ACTIVE_AGENT configuration or constructor parameter.
"""
def __init__(self, active_agent: str = None):
"""Initialize the wrapper with the active agent.
Args:
active_agent: The agent type to use. If None, uses config.ACTIVE_AGENT.
Valid values: config.AGENT_LANGGRAPH, config.AGENT_REACT_LANGGRAPH
"""
if active_agent is None:
active_agent = config.ACTIVE_AGENT
if active_agent == config.AGENT_LANGGRAPH:
from langgraphagent import LangGraphAgent
self.agent = LangGraphAgent()
elif active_agent == config.AGENT_REACT_LANGGRAPH:
from reactlanggraphagent import ReActLangGraphAgent
self.agent = ReActLangGraphAgent()
elif active_agent == config.AGENT_LLAMAINDEX:
from llamaindexagent import LlamaIndexAgent
self.agent = LlamaIndexAgent()
else:
# Default to LangGraph if unknown agent type
print(f"[WARNING] Unknown agent type '{active_agent}', defaulting to {config.AGENT_LANGGRAPH}")
from langgraphagent import LangGraphAgent
self.agent = LangGraphAgent()
def __call__(self, question: str, file_name: str = None) -> str:
"""Invoke the active agent with the given question.
Args:
question: The question to answer
file_name: Optional file name if the question references a file
Returns:
The agent's answer as a string
"""
return self.agent(question, file_name)
|