File size: 800 Bytes
7fca18f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, tool, InferenceClientModel

class QAgent:
    def __init__(self):
        print("BasicAgent initialized.")
    def __call__(self, question: str) -> str:
        print(f"Agent received question (first 50 chars): {question[:50]}...")
        # provider = "nebius"
        model = "Qwen/Qwen2.5-Coder-32B-Instruct"
        api_key = SP_HF_TOK

        agent = CodeAgent(tools=[DuckDuckGoSearchTool, VisitWebpageTool], 
            model=InferenceClientModel(
                model=model, 
                # provider=provider, 
                api_key=api_key),
            add_base_tools=True)

        fixed_answer = agent.run(question)
        print(f"Agent returning fixed answer: {fixed_answer}")
        return fixed_answer