A structured Chain-of-Thought (CoT) reasoning agent built using LLMs with step-by-step planning, tool calling, and JSON-based structured outputs.
- ✅ Breaks down user queries step-by-step (START → PLAN → TOOL → OUTPUT)
- ✅ Uses structured JSON responses
- ✅ Calls external tools when required
- ✅ Retrieves real-time weather information
- ✅ Demonstrates tool-augmented reasoning
- 🧠 A Chain-of-Thought reasoning agent
- 🌦️ A Current Weather Retrieval Agent
- Structured reasoning using START, PLAN, TOOL, and OUTPUT steps
- Tool-calling capability
- Real-time weather retrieval via wttr.in
- JSON schema validation using Pydantic
- Secure API key management using .env
cot_reasoning_agent/ │ ├── aiAgent_pydantic.py ├── requirements.txt └── README.md
git clone https://github.com/your-username/cot-weather-agent.git
python -m venv .venv
Windows (PowerShell):
.venv\Scripts\activate
Mac/Linux:
source .venv/bin/activate
pip install -r requirements.txt
Create a file named:
.env
Add your Google API key:
GOOGLE_API_KEY=your_api_key_here
python cot_weather_agent.py
👉 What is the weather in Delhi? 👉 Solve 45*12/3 👉 What is the weather in Bangalore?
- The user enters a query.
- The model reasons step-by-step using Chain-of-Thought.
- If required, it calls the
get_weather(city)tool. - The tool response is injected back into the reasoning loop.
- The agent generates the final structured OUTPUT.
Fetches current weather using:
https://wttr.in/{city}?format=%C+%t
Returns formatted weather information for the given city.
This project demonstrates:
- How Chain-of-Thought improves reasoning transparency
- How to build tool-augmented LLM agents
- How to structure LLM outputs using JSON schemas
- How to securely manage API keys