| from smolagents import CodeAgent, OpenAIServerModel |
| from smolagents import WikipediaSearchTool, GoogleSearchTool, VisitWebpageTool, PythonInterpreterTool |
|
|
|
|
| def get_prompt(): |
| with open("prompt.txt", "r") as f: |
| return f.read() |
|
|
|
|
| class GAIAAgent: |
| def __init__(self): |
| self.agent = CodeAgent( |
| tools=[ |
| GoogleSearchTool(provider="serper"), |
| VisitWebpageTool(), |
| WikipediaSearchTool(), |
| PythonInterpreterTool(), |
| ], |
| model=OpenAIServerModel(model_id='gpt-4.1', max_tokens=4096, temperature=0), |
| add_base_tools=False, |
| max_steps=15, |
| ) |
| self.prompt = get_prompt() |
|
|
| def __call__(self, question: str) -> str: |
| return self.agent.run(self.prompt, additional_args={"question": question}) |
|
|
|
|
| if __name__ == '__main__': |
| agent = GAIAAgent() |
| agent("What is the meaning of life?") |
|
|