chezhian commited on
Commit
2c4cd8b
·
verified ·
1 Parent(s): 6d7ae53

Create agent.py

Browse files
Files changed (1) hide show
  1. agent.py +28 -0
agent.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agent.py
2
+
3
+ from smolagent import SmolAgent, Tool
4
+ from typing import List, Optional
5
+ import os
6
+ import math
7
+
8
+
9
+ # Example of a simple tool GAIA might need
10
+ class Calculator(Tool):
11
+ name = "calculator"
12
+ description = "Perform basic arithmetic. Input should be a math expression, e.g., '3 + 4 * 2'."
13
+
14
+ def call(self, input: str) -> str:
15
+ try:
16
+ return str(eval(input, {"__builtins__": {}}, math.__dict__))
17
+ except Exception as e:
18
+ return f"Error: {str(e)}"
19
+
20
+
21
+ # Instantiate the agent
22
+ def create_agent() -> SmolAgent:
23
+ agent = SmolAgent(
24
+ model="gpt-4", # or any other allowed model
25
+ hf_token=os.getenv("HF_TOKEN"),
26
+ tools=[Calculator()]
27
+ )
28
+ return agent