lam-ho commited on
Commit
1fa2efd
·
verified ·
1 Parent(s): ed038f6

Update agent.py

Browse files

added mathematical functions

Files changed (1) hide show
  1. agent.py +64 -3
agent.py CHANGED
@@ -1,5 +1,66 @@
1
- from smolagents import HfApiModel, CodeAgent
2
 
3
- manager_agent = CodeAgent(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- )
 
1
+ from smolagents import HfApiModel, CodeAgent, DuckDuckGoSearchTool, tool
2
 
3
+
4
+ @tool
5
+ def add(int: a, int: b) -> int:
6
+ """
7
+ This tool adds two integers together and returns an integer.
8
+
9
+ args:
10
+ a: Integer 1
11
+ b: Integer 2
12
+ """
13
+ return a + b
14
+
15
+ @tool
16
+ def subtract(int: a, int: b) -> int:
17
+ """
18
+ This tool subtracts two integers and returns an integer.
19
+
20
+ args:
21
+ a: Integer 1
22
+ b: Integer 2
23
+ """
24
+ return a - b
25
+
26
+ @tool
27
+ def multiply(int: a, int: b) -> int:
28
+ """
29
+ This tool multiplies two integers together and returns an integer.
30
+
31
+ args:
32
+ a: Integer 1
33
+ b: Integer 2
34
+ """
35
+ return a * b
36
+
37
+ @tool
38
+ def divide(int: a, int: b) -> float:
39
+ """
40
+ This tool divides two integers together and returns a float.
41
+
42
+ args:
43
+ a: Integer 1
44
+ b: Integer 2
45
+ """
46
+ if b == 0:
47
+ raise ValueError("Cannot divide by zero.")
48
+ return a* (1.0) / b
49
+
50
+ tools=[
51
+ add,
52
+ subtract,
53
+ multiply,
54
+ divide
55
+ ]
56
+
57
+
58
+ def create_agent():
59
+ manager_agent = CodeAgent(
60
+ model = HfApiModel(),
61
+
62
+ )
63
+
64
+ return manager_agent
65
 
66
+