Weather Forecast Skill
This skill enables querying weather forecasts using the Open-Meteo API, providing hourly temperature data for any location worldwide.
When to Use This Skill
Activate this skill when:
- - Users ask for weather information or forecasts
- Users inquire about temperatures at specific locations
- Users mention weather-related queries that require current or future data
- Users provide location names and expect weather details
Skill Components
Scripts
The scripts/get_weather.py script provides a reliable, reusable way to fetch weather data from the Open-Meteo API. This script is used instead of writing API calls from scratch each time because:
- - API endpoints and parameters need to be consistent
- Error handling for network requests is standardized
- JSON parsing and data extraction is automated
- The script can be executed without loading into context
References
The references/api_response_format.md contains documentation about the Open-Meteo API response structure, including:
- - Request parameters (latitude, longitude, hourly data types)
- Response format and field meanings
- Time zone handling
- Error conditions
Workflow
When this skill is activated:
- 1. Extract location information from the user's query. This may include:
- City names (e.g., "Beijing", "Shanghai", "New York")
- Specific coordinates (latitude, longitude)
- Descriptive locations (e.g., "my current location")
- 2. Convert location to coordinates:
- If city name is provided, use geocoding to get latitude and longitude
- If coordinates are provided directly, use them as-is
- Common city coordinates (saved in memory): Beijing (39.9042, 116.4074), Shanghai (31.2304, 121.4737), New York (40.7128, -74.0060), London (51.5074, -0.1278), Tokyo (35.6762, 139.6503)
- 3. Execute the weather script using the coordinates:
- Run
scripts/get_weather.py with latitude and longitude parameters
- The script returns structured weather data including hourly temperatures
- 4. Present results to the user in a natural, readable format:
- Summarize key information (current temperature, high/low, forecast)
- Include relevant time information (next 24 hours or specific times mentioned)
- Use units appropriate to the context (Celsius by default, Fahrenheit if requested)
Important Notes
- - The Open-Meteo API provides hourly forecasts, not just current weather
- Temperature values are in Celsius by default
- The API is free and requires no authentication
- Coordinate precision: up to 4 decimal places for better accuracy
- If coordinates are not available for a location, inform the user and ask for coordinates or a different location
Example Interactions
User: "What's the weather like in Beijing?"
Action: Extract "Beijing", use coordinates (39.9042, 116.4074), run script, present forecast
User: "Will it be cold in Tokyo tomorrow?"
Action: Extract "Tokyo" and "tomorrow", use coordinates (35.6762, 139.6503), run script, present tomorrow's temperature
User: "Get the temperature for latitude 52.52 and longitude 13.41"
Action: Use provided coordinates directly, run script, present hourly data
User: "How hot will it be in Shanghai today?"
Action: Extract "Shanghai", use coordinates (31.2304, 121.4737), run script, identify maximum temperature for today
天气预报技能
本技能支持通过Open-Meteo API查询天气预报,提供全球任意地点的逐小时温度数据。
使用场景
在以下情况下激活此技能:
- - 用户询问天气信息或预报
- 用户查询特定地点的温度
- 用户提出需要当前或未来数据的天气相关问题
- 用户提供地点名称并期望获取天气详情
技能组件
脚本
scripts/get_weather.py脚本提供了一种可靠且可复用的方式从Open-Meteo API获取天气数据。使用此脚本而非每次从头编写API调用,原因如下:
- - 需要保持API端点和参数的一致性
- 网络请求的错误处理已标准化
- JSON解析和数据提取已自动化
- 脚本可在不加载到上下文的情况下执行
参考资料
references/apiresponseformat.md包含Open-Meteo API响应结构的文档,包括:
- - 请求参数(纬度、经度、逐小时数据类型)
- 响应格式及字段含义
- 时区处理
- 错误条件
工作流程
当此技能被激活时:
- 1. 提取位置信息 从用户的查询中。这可能包括:
- 城市名称(例如:北京、上海、纽约)
- 具体坐标(纬度、经度)
- 描述性位置(例如:我当前的位置)
- 2. 将位置转换为坐标:
- 如果提供城市名称,使用地理编码获取纬度和经度
- 如果直接提供坐标,则直接使用
- 常用城市坐标(已保存至内存):北京(39.9042, 116.4074)、上海(31.2304, 121.4737)、纽约(40.7128, -74.0060)、伦敦(51.5074, -0.1278)、东京(35.6762, 139.6503)
- 3. 使用坐标执行天气脚本:
- 运行scripts/get_weather.py,传入纬度和经度参数
- 脚本返回包含逐小时温度的结构化天气数据
- 4. 以自然易读的格式向用户呈现结果:
- 总结关键信息(当前温度、最高/最低温度、预报)
- 包含相关时间信息(未来24小时或用户提到的具体时间)
- 根据上下文使用合适的单位(默认摄氏度,如有要求则使用华氏度)
重要说明
- - Open-Meteo API提供逐小时预报,而不仅仅是当前天气
- 温度值默认以摄氏度为单位
- 该API免费使用,无需认证
- 坐标精度:最多保留4位小数以获得更高精度
- 如果无法获取某位置的坐标,请告知用户并请求提供坐标或其他位置
交互示例
用户:北京天气怎么样?
操作:提取北京,使用坐标(39.9042, 116.4074),运行脚本,呈现预报
用户:明天东京会冷吗?
操作:提取东京和明天,使用坐标(35.6762, 139.6503),运行脚本,呈现明天的温度
用户:获取纬度52.52、经度13.41的温度
操作:直接使用提供的坐标,运行脚本,呈现逐小时数据
用户:今天上海会有多热?
操作:提取上海,使用坐标(31.2304, 121.4737),运行脚本,识别今天的最高温度