Spaces:
Runtime error
Runtime error
| from smolagents import HfApiModel, CodeAgent, DuckDuckGoSearchTool, WikipediaSearchTool, tool | |
| def add(a: int, b: int) -> int: | |
| """ | |
| This tool adds two integers together and returns an integer. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| return a + b | |
| def subtract(a: int, b: int) -> int: | |
| """ | |
| This tool subtracts two integers and returns an integer. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| return a - b | |
| def multiply(a: int, b: int) -> int: | |
| """ | |
| This tool multiplies two integers together and returns an integer. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| return a * b | |
| def divide(a: int, b: int) -> int: | |
| """ | |
| This tool divides two integers together and returns a float. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| 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: first int | |
| b: second int | |
| """ | |
| 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 | |