File size: 2,212 Bytes
5cd72ef
b7a99d1
ed66648
b7a99d1
969a6a0
b7a99d1
 
a1bc7d9
769eeba
3e67fd3
769eeba
3e67fd3
b7a99d1
3483ac6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b7a99d1
 
 
 
 
 
 
7e0b4a4
 
 
b7a99d1
 
 
7e0b4a4
 
 
 
 
 
 
 
 
173134e
b7a99d1
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
from smolagents import (InferenceClientModel, CodeAgent, ToolCallingAgent, 
                        DuckDuckGoSearchTool, VisitWebpageTool, FinalAnswerTool,
                        WikipediaSearchTool, PythonInterpreterTool,
                        TransformersModel
                        )

model_id = "deepseek-ai/DeepSeek-R1-0528-Qwen3-8B"
model = InferenceClientModel(
    model_id,
    token=os.getenv('HF_TOKEN')
)

#web_agent = ToolCallingAgent(
#            tools=[
#                DuckDuckGoSearchTool(),
#                VisitWebpageTool(),
#                WikipediaSearchTool()
#            ], 
#            model=model,
#            name="search_agent",
#            description="Runs web searches for you. Give it your query as an argument.",
#        )
#python_agent = CodeAgent(
#            tools=[
#                PythonInterpreterTool()
#            ],
#            model=model,
#            name='python_agent',
#            description='Use additional_authorized_imports for you. You need to do actions and help to answer the questions with python code',
#            additional_authorized_imports=[
#                "json",
#                "pandas",
#                "numpy",
#                "requests",
#                "time",
#                "datetime",
#            ],
#            add_base_tools=True,
#        )

class BasicAgent:
    """An agent who is able to answer questions."""
    def __init__(self):

        # Instantiate Agent
        self.agent = CodeAgent(tools=[
            DuckDuckGoSearchTool(),
            VisitWebpageTool(),
            WikipediaSearchTool(),
            FinalAnswerTool()
        ],
            model=model,
        additional_authorized_imports=[
            "json",
            "pandas",
            "numpy",
            "requests",
            "time",
            "datetime",
            "re"
        ],
        add_base_tools=True,
        )
        
        print("BasicAgent initialized.")
        
    def __call__(self, question: str) -> str:
        print(f"Agent received question: {question}...")
        answer = self.agent.run(question)
        print(f"Agent returning answer: {answer}")
        
        return answer