Spaces:
Running
Running
| from smolagents import ( | |
| CodeAgent, | |
| InferenceClientModel, | |
| DuckDuckGoSearchTool, | |
| VisitWebpageTool, | |
| ) | |
| class BasicAgent: | |
| def __init__(self): | |
| model = InferenceClientModel() | |
| self.agent = CodeAgent( | |
| tools=[ | |
| DuckDuckGoSearchTool(max_results=10), | |
| VisitWebpageTool(), | |
| ], | |
| model=model, | |
| max_steps=15, | |
| planning_interval=4, | |
| ) | |
| def __call__(self, question: str) -> str: | |
| prompt = f""" | |
| Solve the following GAIA benchmark question accurately. | |
| Use web search and webpage browsing whenever useful. | |
| Reason carefully and verify facts when possible. | |
| Your response will be checked using EXACT MATCH. | |
| Return ONLY the final answer. | |
| Do not provide an explanation. | |
| Do not write "FINAL ANSWER". | |
| Do not add introductory or concluding text. | |
| If the answer is a list, follow the exact formatting requested | |
| by the question. | |
| Question: | |
| {question} | |
| """ | |
| result = self.agent.run(prompt) | |
| return str(result).strip() | |
| if __name__ == "__main__": | |
| agent = BasicAgent() | |
| test_question = ( | |
| '.rewsna eht sa "tfel" drow eht fo etisoppo eht etirw ,' | |
| 'ecnetnes siht dnatsrednu uoy fI' | |
| ) | |
| print(agent(test_question)) |