Spaces:
Build error
Build error
Download agent.py from chezhian/agent_course_open: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/chezhian/agent_course_open/resolve/main/agent.py
- Command line
-
hf download hf://spaces/chezhian/agent_course_open/agent.py
-
curl -L -o agent.py https://huggingface.co/spaces/chezhian/agent_course_open/resolve/main/agent.py
721 Bytes
| # 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 | |