File size: 760 Bytes
1c9508d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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"