File size: 1,200 Bytes
a5f2147
 
 
386dcac
9b5b26a
 
 
6aae614
9b5b26a
 
2cefb06
0b67d6c
9e8ab76
0b67d6c
9e8ab76
0b67d6c
 
9e8ab76
 
0b67d6c
 
9e8ab76
1b3edd6
7f442c0
 
 
 
 
 
 
 
 
 
 
 
 
 
9b5b26a
9e8ab76
ca57e9e
9e8ab76
ca57e9e
 
9e8ab76
 
ca57e9e
 
9e8ab76
8c01ffb
ca57e9e
6aae614
ae7a494
a5f2147
 
 
 
2cefb06
9e8ab76
23731d2
8fe992b
9e8ab76
8fe992b
 
9e8ab76
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
import os

HF_TOKEN = os.getenv("HF_TOKEN")
from smolagents import Tool, FinalAnswerTool, ToolCallingAgent, DuckDuckGoSearchTool, tool, LiteLLMModel, PythonInterpreterTool
import datetime
import requests
import pytz
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI


@tool
def sum_tool(a: float, b: float) -> float:
    """
    Returns the sum of two numbers

    Args:
        a: The first value.
        b: The second value.

    """
    return a + b

@tool
def multiply_tool(a: float, b: float) -> float:
    """
    Returns the product of two numbers.

    Args:
        a (float): The first value.
        b (float): The second value.

    Returns:
        float: Product of a and b
    """
    return a * b

@tool
def sub_tool(a: float, b: float) -> float:
    """
    Returns the difference of two numbers

    Args:
        a: The first value.
        b: The second value.

    """
    return a - b


final_answer = FinalAnswerTool()

model = LiteLLMModel(
    model_id="huggingface/google/gemma-2-2b-it",
    api_key=HF_TOKEN
)

agent = ToolCallingAgent(
    tools=[sum_tool, sub_tool, multiply_tool],
    model=model,
    max_steps=3
)

GradioUI(agent).launch()