Spaces:
Runtime error
Runtime error
File size: 1,499 Bytes
73e8255 57ee912 1fa2efd 73e8255 1fa2efd 73e8255 1fa2efd 73e8255 1fa2efd 73e8255 1fa2efd 73e8255 1fa2efd 73e8255 1fa2efd 73e8255 1fa2efd 73e8255 1fa2efd 73e8255 57ee912 1fa2efd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
from smolagents import HfApiModel, CodeAgent, DuckDuckGoSearchTool, WikipediaSearchTool, tool
@tool
def add(a: int, b: int) -> int:
"""
This tool adds two integers together and returns an integer.
args:
a: Integer 1
b: Integer 2
"""
return a + b
@tool
def subtract(a: int, b: int) -> int:
"""
This tool subtracts two integers and returns an integer.
args:
a: Integer 1
b: Integer 2
"""
return a - b
@tool
def multiply(a: int, b: int) -> int:
"""
This tool multiplies two integers together and returns an integer.
args:
a: Integer 1
b: Integer 2
"""
return a * b
@tool
def divide(a: int, b: int) -> int:
"""
This tool divides two integers together and returns a float.
args:
a: Integer 1
b: Integer 2
"""
if b == 0:
raise ValueError("Cannot divide by zero.")
return a* (1.0) / b
def modulo(a: int, b: int) -> float:
"""
This tool returns the modulus of two integers
args:
a: Integer 1
b: Integer 2
"""
return a % b
tools=[
add,
subtract,
multiply,
divide,
modulo,
DuckDuckGoSearchTool(),
WikipediaSearchTool()
]
def create_agent():
agent = CodeAgent(
model = HfApiModel(),
tools = tools,
max_steps=10,
verbosity_level=2
)
return agent
|