Skip to main content

Production-ready AI-powered conversational weather assistant built with LangGraph

Project description

๐ŸŒค๏ธ Codex Weather Agent

PyPI version Python 3.9+ License: MIT

An AI-powered conversational weather assistant 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

  • ๐Ÿค– Conversational AI: 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.0.tar.gz (22.4 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.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file codex_weather_agent-1.0.0.tar.gz.

File metadata

  • Download URL: codex_weather_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 22.4 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.0.tar.gz
Algorithm Hash digest
SHA256 6276ad30a4c89a88d59ce851f60cdf4518cbb6d06029a89a55c45191d7e3251f
MD5 47540fa0fcedebe1d174c36647bfc387
BLAKE2b-256 8c46a13596baf22814ee047ddf392580797987b5ef820e5b4dc0611177492ec8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for codex_weather_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0267e2edc9682c318c4279256529774806466963ef787b34bc8fa36dff503b2
MD5 95b49978046a7f7d89774fb25cb8813d
BLAKE2b-256 fe0ae2a9ff267fc5fbc5e438ad8118c8b78dad2f5f0950352be5a792ee9e9b23

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