| from smolagents import InferenceClientModel, CodeAgent, WebSearchTool | |
| from tools import multiply, add, subtract, divide, modulus, wiki_search, arvix_search | |
| model = InferenceClientModel(provider="together", model_id="Qwen/Qwen3-235B-A22B-FP8") | |
| agent = CodeAgent( | |
| model=model, | |
| tools=[multiply, add, subtract, divide, modulus, wiki_search, arvix_search, WebSearchTool()], | |
| additional_authorized_imports=["time", "numpy", "pandas"], | |
| max_steps=20, | |
| ) | |
| def get_agent_response(question: str) -> str: | |
| """Get the agent's response to a question.""" | |
| try: | |
| response = agent.run(question) | |
| return response | |
| except Exception as e: | |
| print(f"Error during agent invocation: {e}") | |
| return "Error during agent invocation" | |