Spaces:
Runtime error
Runtime error
Update agent.py
Browse filesadded more tools
agent.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
from smolagents import HfApiModel, CodeAgent, DuckDuckGoSearchTool, tool
|
2 |
|
3 |
|
4 |
@tool
|
5 |
-
def add(
|
6 |
"""
|
7 |
This tool adds two integers together and returns an integer.
|
8 |
|
@@ -13,7 +13,7 @@ def add(int: a, int: b) -> int:
|
|
13 |
return a + b
|
14 |
|
15 |
@tool
|
16 |
-
def subtract(
|
17 |
"""
|
18 |
This tool subtracts two integers and returns an integer.
|
19 |
|
@@ -24,7 +24,7 @@ def subtract(int: a, int: b) -> int:
|
|
24 |
return a - b
|
25 |
|
26 |
@tool
|
27 |
-
def multiply(
|
28 |
"""
|
29 |
This tool multiplies two integers together and returns an integer.
|
30 |
|
@@ -35,7 +35,7 @@ def multiply(int: a, int: b) -> int:
|
|
35 |
return a * b
|
36 |
|
37 |
@tool
|
38 |
-
def divide(
|
39 |
"""
|
40 |
This tool divides two integers together and returns a float.
|
41 |
|
@@ -47,20 +47,35 @@ def divide(int: a, int: b) -> float:
|
|
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 |
-
|
60 |
model = HfApiModel(),
|
61 |
-
|
|
|
|
|
62 |
)
|
63 |
|
64 |
-
return
|
65 |
|
66 |
|
|
|
1 |
+
from smolagents import HfApiModel, CodeAgent, DuckDuckGoSearchTool, WikipediaSearchTool, tool
|
2 |
|
3 |
|
4 |
@tool
|
5 |
+
def add(a: int, b: int) -> int:
|
6 |
"""
|
7 |
This tool adds two integers together and returns an integer.
|
8 |
|
|
|
13 |
return a + b
|
14 |
|
15 |
@tool
|
16 |
+
def subtract(a: int, b: int) -> int:
|
17 |
"""
|
18 |
This tool subtracts two integers and returns an integer.
|
19 |
|
|
|
24 |
return a - b
|
25 |
|
26 |
@tool
|
27 |
+
def multiply(a: int, b: int) -> int:
|
28 |
"""
|
29 |
This tool multiplies two integers together and returns an integer.
|
30 |
|
|
|
35 |
return a * b
|
36 |
|
37 |
@tool
|
38 |
+
def divide(a: int, b: int) -> int:
|
39 |
"""
|
40 |
This tool divides two integers together and returns a float.
|
41 |
|
|
|
47 |
raise ValueError("Cannot divide by zero.")
|
48 |
return a* (1.0) / b
|
49 |
|
50 |
+
def modulo(a: int, b: int) -> float:
|
51 |
+
"""
|
52 |
+
This tool returns the modulus of two integers
|
53 |
+
|
54 |
+
args:
|
55 |
+
a: Integer 1
|
56 |
+
b: Integer 2
|
57 |
+
"""
|
58 |
+
return a % b
|
59 |
+
|
60 |
tools=[
|
61 |
add,
|
62 |
subtract,
|
63 |
multiply,
|
64 |
+
divide,
|
65 |
+
modulo,
|
66 |
+
DuckDuckGoSearchTool(),
|
67 |
+
WikipediaSearchTool()
|
68 |
]
|
69 |
|
70 |
|
71 |
def create_agent():
|
72 |
+
agent = CodeAgent(
|
73 |
model = HfApiModel(),
|
74 |
+
tools = tools,
|
75 |
+
max_steps=10,
|
76 |
+
verbosity_level=2
|
77 |
)
|
78 |
|
79 |
+
return agent
|
80 |
|
81 |
|