File size: 1,447 Bytes
2125ce6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sys
import os

# Add the Project Root to sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

from smolagents import (
    HfApiModel,
    CodeAgent,
    load_tool,
    Tool,
    InferenceClientModel,
    ToolCallingAgent,
    FinalAnswerTool,
    DuckDuckGoSearchTool,
    VisitWebpageTool,
    GoogleSearchTool,
    PythonInterpreterTool,
)
import os
from huggingface_hub import login
from dotenv import load_dotenv
from data.sample_questions import QUESTIONS

# from tools.visit_website import VisitWebpageTool

load_dotenv()
login(os.environ["HF_API_KEY"])

# Tools

# wikipedia = Tool.from_langchain(load_tool("wikipedia", trust_remote_code=True))

tools = [
    # DuckDuckGoSearchTool(),
    # VisitWebpageTool(),
    PythonInterpreterTool(),
    FinalAnswerTool(),
    # wikipedia
]

question = QUESTIONS[0]

# LLM Model
model = HfApiModel(
    "deepseek-ai/DeepSeek-R1",
    provider="together",
    # max_tokens=40096,
    # temperature=0.1,
    # token=get_huggingface_token(),
)

# Code Agent
hf_code_agent = CodeAgent(
    model=model,
    tools=tools,
    max_steps=20,
    additional_authorized_imports=["pandas", "numpy", "time", "bs4", "time"],
    verbosity_level=2,
    name="python_interpreter_agent",
    description="Can run and execute python code."
)

hf_code_agent.logger.console.width = 66


if __name__ == "__main__":
    answer = hf_code_agent.run(question)
    print(answer)