Calculator Agent
A mathematical calculator agent with various calculation tools using the OpenAI API.Features
The calculator agent provides 8 specialized mathematical tools:Basic Arithmetic
- add_numbers - Addition of two numbers
- subtract_numbers - Subtraction
- multiply_numbers - Multiplication
- divide_numbers - Division (with zero-check)
Financial Calculations
- calculate_compound_interest - Compound interest calculator with customizable compounding periods
Geometric Calculations
- calculate_circle_area - Circle area from radius
- calculate_triangle_area - Triangle area from base and height
Unit Conversions
- convert_temperature - Temperature conversion between Celsius, Fahrenheit, and Kelvin
Setup
1. Install Dependencies
openai-agents- OpenAI Agents SDK with all dependencies
2. Set OpenAI API Key
3. Deploy with Orpheus
Usage
Example Queries
Try these calculation requests:Testing with Orpheus
Once deployed, invoke the agent:Configuration
Agent settings fromagent.yaml:
| Setting | Value | Description |
|---|---|---|
| runtime | python3 | Python runtime |
| module | calculator | calculator.py filename |
| entrypoint | handler | Handler function name |
| memory | 256MB | Memory allocation |
| timeout | 180s | Request timeout |
Tool Details
add_numbers(a, b)
subtract_numbers(a, b)
multiply_numbers(a, b)
divide_numbers(a, b)
calculate_compound_interest(principal, rate, time, compounds_per_year=1)
calculate_circle_area(radius)
calculate_triangle_area(base, height)
convert_temperature(temperature, from_unit, to_unit)
Error Handling
The agent handles errors gracefully:- Missing query: Returns error with usage instructions
- Division by zero: Tool returns error message
- Invalid values: Tools validate inputs (negative radius, etc.)
- API failures: Handler catches exceptions and returns error dict
File Structure
Troubleshooting
Agent fails with “OPENAI_API_KEY not found”
Set the environment variable before starting the server:Timeout errors
Increase timeout inagent.yaml if calculations take longer than 60s:
Import errors
Run setup.sh to install dependencies:Next Steps
- Deploy the agent:
orpheus deploy . - Test with example queries above
- Try more complex calculations and tool combinations
Source Code
- agent.yaml

