Calculator enables an Agent to perform mathematical calculations.

Example

The following agent will calculate the result of 10*5 and then raise it to the power of 2:
cookbook/tools/calculator_tools.py
from agno.agent import Agent
from agno.tools.calculator import CalculatorTools

agent = Agent(
    tools=[
        CalculatorTools()
    ],
        markdown=True,
)

agent.print_response("What is 10*5 then to the power of 2, do it step by step")

Toolkit Functions

FunctionDescription
addAdds two numbers and returns the result.
subtractSubtracts the second number from the first and returns the result.
multiplyMultiplies two numbers and returns the result.
divideDivides the first number by the second and returns the result. Handles division by zero.
exponentiateRaises the first number to the power of the second number and returns the result.
factorialCalculates the factorial of a number and returns the result. Handles negative numbers.
is_primeChecks if a number is prime and returns the result.
square_rootCalculates the square root of a number and returns the result. Handles negative numbers.
You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.

Developer Resources