> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getbindu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 2.2 Weather Research

> Weather intelligence agent providing real-time weather data and forecasts

Weather intelligence agent providing real-time weather data and forecasts.

## Code

Create `weather-research.py` with the code below, or save it directly from your editor.

```python theme={null}
import os
from dotenv import load_dotenv
from bindu.penguin.bindufy import bindufy
from agno.agent import Agent
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.models.openrouter import OpenRouter

load_dotenv()

agent = Agent(
    instructions="You are a weather research assistant. When asked about weather, provide a clear, concise weather report with current conditions, temperature, and forecast. Focus on the most relevant information and present it in an organized, easy-to-read format. Avoid showing multiple search results - synthesize the information into a single coherent response.",
    model=OpenRouter(
        id="openai/gpt-oss-120b",
        api_key=os.getenv("OPENROUTER_API_KEY")
    ),
    tools=[DuckDuckGoTools()],
)

config = {
    "author": "bindu.builder@getbindu.com",
    "name": "weather_research_agent",
    "description": "Research agent that finds current weather and forecasts for any city worldwide",
    "deployment": {
        "url": "http://localhost:3773",
        "expose": True,
        "cors_origins": ["http://localhost:5173"]
    },
    "skills": ["skills/weather-research-skill"],
}

def handler(messages: list[dict[str, str]]):
    if messages:
        latest_message = messages[-1].get('content', '') if isinstance(messages[-1], dict) else str(messages[-1])
        result = agent.run(input=latest_message)
        
        if hasattr(result, 'content'):
            return result.content
        elif hasattr(result, 'response'):
            return result.response
        else:
            return str(result)
    
    return "Please provide a location for weather information."

bindufy(config, handler)

#bindufy(config, handler, launch=True)
# This will create a tunnel to your agent and expose it on port 3773
```

## Skill Configuration

Create `skills/weather-research-skill/skill.yaml`:

```yaml theme={null}
# Weather Research Skill
# Advanced weather research with comprehensive meteorological analysis

id: weather-research-skill
name: weather-research-skill
version: 1.0.0
author: bindu.builder@getbindu.com

description: |
  Advanced weather research skill that provides comprehensive weather information,
  forecasts, and meteorological analysis for any location worldwide.

  Features:
  - Real-time weather data via search
  - Multi-day forecasting with confidence levels
  - Historical weather pattern analysis
  - Travel recommendations based on weather
  - Severe weather alerts
  - Climate information and trends

  Uses DuckDuckGo search to find current weather conditions
  and provides detailed analysis with both metric and imperial units.
tags:
  - weather
  - forecast
  - meteorology
  - research
  - climate
  - travel
input_modes:
  - application/json
output_modes:
  - application/json
examples:
  - "Get current weather conditions for New York City"
  - "Provide 5-day weather forecast for London"
  - "Analyze weather patterns for Tokyo"
  - "What's the weather like in Dehradun?"
  - "Give travel recommendations for Paris this weekend"
capabilities_detail:
  weather_research:
    supported: true
    description: "Comprehensive weather research and forecasting capabilities"
  search_integration:
    supported: true
    description: "Real-time weather data search via DuckDuckGo"
  forecasting:
    supported: true
    description: "Multi-day weather forecasts with confidence levels"
  analysis:
    supported: true
    description: "Weather pattern analysis and trends"
```

## How It Works

**Weather Instructions**

* Clear directive: "Provide clear, concise weather report"
* Synthesizes information from multiple sources
* Organized, easy-to-read format
* Avoids raw search results

**Handler**

* Extracts latest message content
* Handles different message formats
* Returns clean response (content, response, or string)
* Fallback message if no location provided

**Tools**

* `DuckDuckGoTools()`: Real-time web search
* Searches for current weather data
* Finds forecasts for any location worldwide

**Model**

* `openai/gpt-oss-120b`: Advanced reasoning
* Synthesizes multiple search results
* Formats weather data clearly

## Dependencies

```bash theme={null}
uv init
uv add bindu agno python-dotenv
```

## Environment Setup

Create `.env` file:

```bash theme={null}
OPENROUTER_API_KEY=your_openrouter_api_key_here
```

## Run

```bash theme={null}
uv run weather-research.py
```

**Examples:**

* "What's the weather like in New York City?"
* "Check the weather forecast for London this weekend"
* "What's the temperature in Tokyo right now?"

## Example API Calls

<AccordionGroup>
  <Accordion title="Message Send Request">
    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "method": "message/send",
      "params": {
        "message": {
          "role": "user",
          "kind": "message",
          "messageId": "9f11c870-5616-49ad-b187-d93cbb100001",
          "contextId": "9f11c870-5616-49ad-b187-d93cbb100002",
          "taskId": "9f11c870-5616-49ad-b187-d93cbb100003",
          "parts": [
            {
              "kind": "text",
              "text": "What's the weather like in New York City?"
            }
          ]
        },
         "skillId": "weather-research-skill",
        "configuration": {
          "acceptedOutputModes": ["application/json"]
        }
      },
      "id": "9f11c870-5616-49ad-b187-d93cbb100003"
    }
    ```
  </Accordion>

  <Accordion title="Task get Request">
    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "method": "tasks/get",
      "params": {
        "taskId": "9f11c870-5616-49ad-b187-d93cbb100003"
      },
      "id": "9f11c870-5616-49ad-b187-d93cbb100004"
    }
    ```
  </Accordion>
</AccordionGroup>

## Frontend Setup

```bash theme={null}
# Clone the Bindu repository
git clone https://github.com/GetBindu/Bindu

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Start frontend development server
npm run dev
```

Open [http://localhost:5173](http://localhost:5173) and try to chat with the weather research agent
