Spaces:
Sleeping
Sleeping
File size: 2,694 Bytes
a08fec1 079da56 a08fec1 079da56 a08fec1 |
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
from smolagents import InferenceClientModel, CodeAgent, GoogleSearchTool, VisitWebpageTool, WikipediaSearchTool
from tool.SupadataTool import SupadataTool
from tool.UnknownTextTool import UnknownTextTool, BasicMathTool
class GaiaAgent:
def __init__(self):
manager_model = InferenceClientModel(
model_id='Qwen/Qwen3-30B-A3B-Thinking-2507',
provider='nebius',
max_tokens=8096,
)
agent_model = InferenceClientModel(
"mistralai/Devstral-Small-2505",
provider="nebius",
max_tokens=8096
)
self.web_agent = CodeAgent(
model=agent_model,
tools=[
GoogleSearchTool(provider="serper"),
VisitWebpageTool()
],
name="web_agent",
description="Browses the web to find information",
verbosity_level=0,
max_steps=10,
)
self.wikipedia_agent = CodeAgent(
model=agent_model,
tools=[WikipediaSearchTool()],
name="wikipedia_agent",
description="Searches Wikipedia and returns a summary or full text of the given topic, along with the page URL. If you need to get any encyclopedia information, use this tool.",
max_steps=5,
)
self.text_agent = CodeAgent(
model=agent_model,
tools=[UnknownTextTool(), BasicMathTool()],
name="text_agent",
description="This agent is perfect for solving specific tasks: * decoding unknown text (if you have unknown text, use this tool); * math and algorithmic problems add, subtract, multiply, divide, etc.",
)
self.youtube_transcript_agent = CodeAgent(
model=agent_model,
tools=[SupadataTool()],
name="youtube_transcript_agent",
description="This agent is perfect for generating transcripts of YouTube videos. If you need to know what the video is about, use this tool.",
)
self.manager_agent = CodeAgent(
tools=[],
model=manager_model,
managed_agents=[self.web_agent, self.wikipedia_agent, self.text_agent, self.youtube_transcript_agent],
additional_authorized_imports=[
],
planning_interval=5,
verbosity_level=2,
max_steps=15,
)
print("GaiaAgent initialized.")
def __call__(self, question: str) -> str:
print(f"Agent received question (first 50 chars): {question[:50]}...")
answer = self.manager_agent.run(question)
print(f"Agent returning fixed answer: {answer}")
return answer |