Calculator agent (beginners)
Calculator Agent
Build an AI agent that acts as a calculator using SpinAI
Overview
A simple calculator agent that demonstrates core SpinAI concepts. The agent:
- Processes mathematical expressions in natural language
- Dynamically chooses between addition and subtraction operations
- Returns numerical results
Structure
Quick Start
- Create a new project:
-
Select the default template
-
Set up your environment:
How It Works
- Agent Setup: Uses OpenAI (swappable with any supported LLM) for decision making
- Available Actions:
sum
: Adds two numbersminus
: Subtracts two numbers
- Input Processing: Converts natural language (e.g. “What is 5 plus 3 - 1?”) into mathematical operations
- State Management: Tracks calculation progress through multiple operations
Example Usage
Next Steps
Here are some easy things you can add to get your hands dirty and learn how Spin works
- Add a multiply action
- Add a division action
- Try to use the state returned by the agent call to keep a running sum that you can continue performing mathematical operations on, like a real calculator
- Add any agentId (i.e “calculator-agent”) and your SpinAPI key to the createAgent parameters and track your model on our dashboard.
This example serves as a basic introduction to Spin’s framework.