Skip to main content

Production-ready conversational weather assistant built with LangGraph

Project description

๐ŸŒค๏ธ Codex Weather Agent

PyPI version Python 3.9+ License: MIT

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

๐Ÿ“ž Support


๐ŸŒค๏ธ 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

codex_weather_agent-1.0.3.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_weather_agent-1.0.3-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

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

Hashes for codex_weather_agent-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9a510a2a611f76e39bf450bc39e0bff2f320f9d3ec082afd06b16f309b76ea5b
MD5 4156360f177a8c00db18f07ee8c22389
BLAKE2b-256 e98f4998ef1f8ae63725e0a1b8c332ce51b16ef285c5cffae7f89b585e512c7c

See more details on using hashes here.

File details

Details for the file codex_weather_agent-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for codex_weather_agent-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3b37addbae7bfcbaa4520166a7904e3bc669815be979e295265e78071335268a
MD5 05a8d7ab117535199927228c4af4e7e6
BLAKE2b-256 bcf41bd45b7b840860307ad56a584e845792cb64351f8f3ec4774b1985486f68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page