File size: 721 Bytes
2c4cd8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# agent.py

from smolagent import SmolAgent, Tool
from typing import List, Optional
import os
import math


# Example of a simple tool GAIA might need
class Calculator(Tool):
    name = "calculator"
    description = "Perform basic arithmetic. Input should be a math expression, e.g., '3 + 4 * 2'."

    def call(self, input: str) -> str:
        try:
            return str(eval(input, {"__builtins__": {}}, math.__dict__))
        except Exception as e:
            return f"Error: {str(e)}"


# Instantiate the agent
def create_agent() -> SmolAgent:
    agent = SmolAgent(
        model="gpt-4",  # or any other allowed model
        hf_token=os.getenv("HF_TOKEN"),
        tools=[Calculator()]
    )
    return agent