Spaces:
Build error
Build error
# 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 | |