Copy
Ask AI
"""
Calculator Tools
=============================
Demonstrates calculator tools.
"""
from agno.agent import Agent
from agno.tools.calculator import CalculatorTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# Example 1: Include specific calculator functions for basic operations
basic_calc_agent = Agent(
tools=[CalculatorTools(include_tools=["add", "subtract", "multiply", "divide"])],
markdown=True,
)
# Example 2: Exclude advanced functions for simple use cases
simple_calc_agent = Agent(
tools=[CalculatorTools(exclude_tools=["factorial", "is_prime", "exponentiate"])],
markdown=True,
)
# Example 3: Full calculator functionality (default)
agent = Agent(
tools=[CalculatorTools()],
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
simple_calc_agent.print_response(
"What is 10*5 then to the power of 2, do it step by step"
)
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python calculator_tools.py