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