An intelligent calculator agent built with LangChain, and Groq Llama 3.3 that performs mathematical operations using tool calling instead of solving everything inside the language model.
This project demonstrates how modern AI agents can decide when to use external tools. Instead of directly calculating answers, the LLM selects the appropriate tool, executes it, and then generates a natural-language response.
User
What is 42 + 58?
Agent Reasoning
LLM → Calls add(a=42, b=58)
Tool → Returns 100
LLM → "The answer is 100."
- ➕ Addition
- ➖ Subtraction
- ✖️ Multiplication
- ➗ Division
- √ Square Root
- 🤖 Automatic tool selection
- 🔄 Agent execution
- 📖 Easy to extend with custom tools
- Python 3.10+
- LangChain
- LangChain Groq
- Groq API
- Llama 3.3 70B Versatile
.
├── app.py
├── .env
├── requirements.txt
└── README.md
git clone https://github.com/Vinay-Rai/AI-Calculator-Agent
cd AI-Calculator-Agentpython -m venv myenvActivate it:
Windows
myenv\Scripts\activateLinux/macOS
source myenv/bin/activatepip install -r requirements.txtGROQ_API_KEY=your_groq_api_keypython app.pyWhat is 42 + 58?
Multiply 15 by 8.
Divide 120 by 5.
What is the square root of 144?
I have a rectangle with width 12 and height 7.
Find the area and then calculate its square root.
User Question
│
▼
LangChain Agent
│
▼
LLM decides which tool to use
│
▼
Tool Execution
│
▼
Tool Result
│
▼
LLM generates final response
- Memory-enabled conversations
- Weather API integration
- Web Search tools
- File Reader (PDF, CSV, DOCX)
- Database querying
- Multi-tool reasoning
- Streamlit web interface
Contributions, suggestions, and improvements are welcome.
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a Pull Request
This project is licensed under the MIT License.
Vinay Rai
If you found this project helpful, consider giving it a ⭐ on GitHub!