Production-ready conversational weather assistant built with LangGraph
Project description
๐ค๏ธ Codex Weather Agent
A professional conversational weather service built with LangGraph, supporting multiple LLM providers (OpenAI, Azure OpenAI, Gemini, Claude) and providing real-time weather data through a production-ready Python API.
โจ Features
- ๐ค Natural Conversations: Intuitive natural language interactions powered by LangGraph workflows
- ๐ Multiple LLM Support: OpenAI, Azure OpenAI, Google Gemini, and Anthropic Claude
- ๐ฆ๏ธ Comprehensive Weather Data: Current conditions, forecasts, and air quality
- ๐ Location Intelligence: Automatic location detection and coordinate lookup
- โ๏ธ Flexible Configuration: Environment variables and programmatic setup
- ๐ง Easy Integration: Production-ready Python library for applications
- ๐ Proper Logging: Structured logging with configurable levels
- ๐ก๏ธ Error Handling: Robust error handling and validation
๐ Installation
From PyPI
pip install codex-weather-agent
From Source
git clone https://github.com/CodexJitin/Weather-Agent.git
cd Weather-Agent
pip install -e .
โ๏ธ Configuration
1. Get API Keys
You'll need:
- OpenWeatherMap API Key: Get it here (Required)
- LLM Provider API Key: Choose from OpenAI, Azure OpenAI, Google Gemini, or Anthropic Claude
2. Environment Setup
Create a .env file (copy from .env.example):
# Weather API (Required)
OPENWEATHER_API_KEY=your_openweather_api_key_here
# Choose your LLM provider
LLM_PROVIDER=openai
# OpenAI (default)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-3.5-turbo
# Or Azure OpenAI
AZURE_OPENAI_API_KEY=your_azure_key_here
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT_NAME=your_deployment_name
AZURE_OPENAI_MODEL=gpt-35-turbo
# Or Google Gemini
GOOGLE_API_KEY=your_google_api_key_here
GEMINI_MODEL=gemini-pro
# Or Anthropic Claude
ANTHROPIC_API_KEY=your_anthropic_api_key_here
CLAUDE_MODEL=claude-3-sonnet-20240229
๐ฏ Usage
Basic Library Usage
from codex_weather_agent import WeatherAgent
from codex_weather_agent.logging_config import setup_logging
# Set up logging (optional)
setup_logging(level="INFO")
# Method 1: Use environment variables (recommended)
agent = WeatherAgent(provider_name="openai")
response = agent.query("What's the weather in Tokyo?")
print(response)
# Method 2: Pass API keys directly
agent = WeatherAgent(
provider_name="openai",
provider_config={
"api_key": "your-openai-api-key",
"model": "gpt-4"
},
openweather_api_key="your-openweather-api-key"
)
# Method 3: Use configuration object
from codex_weather_agent import WeatherAgentConfig
config = WeatherAgentConfig(
llm_provider="openai",
openweather_api_key="your-openweather-api-key"
)
config.update_llm_config(api_key="your-openai-api-key", model="gpt-4")
agent = WeatherAgent.from_config(config)
response = agent.query("Air quality in Delhi?")
Advanced Configuration
from weather_agent_langgraph import WeatherAgent
# Configure different LLM providers
configs = {
"openai": {
"api_key": "sk-...",
"model": "gpt-4",
"temperature": 0
},
"azure": {
"api_key": "your-key",
"azure_endpoint": "https://your-resource.openai.azure.com/",
"deployment_name": "gpt-35-turbo",
"model": "gpt-35-turbo"
},
"gemini": {
"api_key": "your-google-key",
"model": "gemini-pro"
},
"claude": {
"api_key": "your-anthropic-key",
"model": "claude-3-sonnet-20240229"
}
}
# Create agent with specific provider
agent = WeatherAgent(
provider_name="gemini",
provider_config=configs["gemini"]
)
๐ Example Queries
The agent understands natural language queries:
- "What's the weather in New York?"
- "Give me the air quality for Delhi"
- "5-day forecast for London"
- "Is it raining in my location?"
- "Compare weather between Tokyo and Paris"
- "What should I wear in Mumbai today?"
๐๏ธ Architecture
The package uses a LangGraph workflow with the following components:
- Agent: Main orchestrator class
- Workflow: LangGraph state machine for query processing
- Tools: Weather data collection (OpenWeatherMap API)
- LLM Providers: Abstraction layer for different AI models
- State Management: Conversation and tool execution tracking
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ User Query โโโโโถโ LangGraph โโโโโถโ AI Response โ
โ โ โ Workflow โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Weather Tools โ
โ โข Current โ
โ โข Forecast โ
โ โข Air Quality โ
โ โข Location โ
โโโโโโโโโโโโโโโโโโโโ
๐ ๏ธ Development
# Clone the repository
git clone https://github.com/CodexJitin/Codex-Weather-Agent.git
cd Codex-Weather-Agent
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/
isort src/
๐ Requirements
- Python 3.8+
- OpenWeatherMap API key
- One of the supported LLM provider API keys:
- OpenAI API key
- Azure OpenAI credentials
- Google AI Studio API key (for Gemini)
- Anthropic API key (for Claude)
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- LangChain and LangGraph for the AI framework
- OpenWeatherMap for weather data
- Rich for beautiful CLI interfaces
๐ Support
- ๐ซ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
๐ค๏ธ Weather Agent LangGraph
AI-powered weather intelligence at your fingertips
Built with โค๏ธ by CodexJitin
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_weather_agent-1.0.3.tar.gz.
File metadata
- Download URL: codex_weather_agent-1.0.3.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a510a2a611f76e39bf450bc39e0bff2f320f9d3ec082afd06b16f309b76ea5b
|
|
| MD5 |
4156360f177a8c00db18f07ee8c22389
|
|
| BLAKE2b-256 |
e98f4998ef1f8ae63725e0a1b8c332ce51b16ef285c5cffae7f89b585e512c7c
|
File details
Details for the file codex_weather_agent-1.0.3-py3-none-any.whl.
File metadata
- Download URL: codex_weather_agent-1.0.3-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b37addbae7bfcbaa4520166a7904e3bc669815be979e295265e78071335268a
|
|
| MD5 |
05a8d7ab117535199927228c4af4e7e6
|
|
| BLAKE2b-256 |
bcf41bd45b7b840860307ad56a584e845792cb64351f8f3ec4774b1985486f68
|