Weather Query Skill
This skill enables AI agents to fetch real-time weather information and forecasts for locations in China using the provided shell scripts.
When to Use This Skill
Use this skill when users:
- - Ask about current weather conditions
- Want weather forecasts
- Need temperature, humidity, wind information
- Request air quality data
- Plan outdoor activities and need weather info
How to Use
Get Real-time Weather
Use the
realtime.sh script to get current conditions, air quality, daily life indices, and weather alerts.
CODEBLOCK0
Get Weather Forecast
Use the
forecast.sh script to get hourly and daily forecast data, along with sunrise/sunset times.
./scripts/forecast.sh <query> [--encoding <text|json|markdown>] [--days <0-8>]
- -
query (Required): The name of the city, district, or area in Chinese (e.g., 雨花台, 北京). Can be provided as a positional argument or with --query. - INLINECODE6 (Optional): Used to specify the returned data format. Can be
text, json, or markdown. - INLINECODE10 (Optional, forecast only): Used to specify the weather forecast date range. An integer between 0 and 8.
Response Format
To balance information depth with token consumption, you MUST use the following rules for the encoding parameter:
- 1. Default Strategy (
--encoding markdown)
-
When to use: By default for standard weather inquiries.
-
Why: Provides well-structured, easy-to-read information with moderate token usage.
- 2. Brief Information (
--encoding text)
-
When to use: When the user explicitly requests brief or summarized weather information.
-
Why: Returns only essential details in plain text, saving maximum tokens.
- 3. Complete Information (
--encoding json)
-
When to use: Only when the user explicitly asks for raw data, detailed fields, or comprehensive data (all indices, timestamps).
-
Why: Returns the complete API payload, which is highly token-heavy.
Best Practices
- 1. Location Names: Always use Chinese characters for location names
- Error Handling: Check if the location is valid before displaying results
- Context: Provide relevant context based on weather conditions
- Rain: Suggest bringing umbrella
- Hot: Recommend staying hydrated
- Cold: Advise wearing warm clothes
- Poor AQI: Suggest wearing mask
- 4. Fallbacks: If a specific district doesn't work, try the city name
Troubleshooting
Issue: Location not found
- - Solution: Try using the main city name instead of district
- Example: Use "北京" instead of "朝阳区"
Issue: No forecast data
- - Solution: Verify the location name is correct
- Try standard city names: 北京, 上海, 广州, 深圳, etc.
Issue: Data seems outdated
- - Solution: The API updates regularly, but weather can change quickly
- Check the
updated timestamp in the response
Supported Locations
The weather API supports most cities and districts in China, including:
- - Provincial capitals: 北京, 上海, 广州, 深圳, 成都, 杭州, 南京, 武汉, etc.
- Major cities: 苏州, 青岛, 大连, 厦门, etc.
- Districts: 海淀区, 朝阳区, 浦东新区, etc.
天气查询技能
此技能使AI代理能够使用提供的Shell脚本获取中国地区的实时天气信息和预报。
何时使用此技能
当用户出现以下情况时使用此技能:
- - 询问当前天气状况
- 需要天气预报
- 查询温度、湿度、风力信息
- 请求空气质量数据
- 计划户外活动并需要天气信息
使用方法
获取实时天气
使用realtime.sh脚本获取当前状况、空气质量、生活指数和天气预警。
bash
./scripts/realtime.sh <查询地点> [--encoding
]
获取天气预报
使用forecast.sh脚本获取逐小时和逐日预报数据,以及日出/日落时间。
bash
./scripts/forecast.sh <查询地点> [--encoding ] [--days <0-8>]
- - query(必填):城市、区或地区的中文名称(例如:雨花台、北京)。可作为位置参数或使用--query提供。
- encoding(可选):用于指定返回的数据格式。可选值为text、json或markdown。
- days(可选,仅限预报):用于指定天气预报的日期范围。取值范围为0到8的整数。
响应格式
为了在信息深度和令牌消耗之间取得平衡,您必须对encoding参数使用以下规则:
- 1. 默认策略(--encoding markdown)
- 使用时机: 标准天气查询的默认选项。
- 原因: 提供结构清晰、易于阅读的信息,令牌消耗适中。
- 2. 简要信息(--encoding text)
- 使用时机: 当用户明确要求简要或概括的天气信息时。
- 原因: 仅以纯文本形式返回基本细节,最大限度节省令牌。
- 3. 完整信息(--encoding json)
- 使用时机: 仅当用户明确要求原始数据、详细字段或全面数据(所有指数、时间戳)时。
- 原因: 返回完整的API负载,令牌消耗极高。
最佳实践
- 1. 地点名称:始终使用中文字符表示地点名称
- 错误处理:在显示结果前检查地点是否有效
- 上下文关联:根据天气状况提供相关建议
- 雨天:建议携带雨伞
- 炎热:建议补充水分
- 寒冷:建议穿着保暖衣物
- 空气质量差:建议佩戴口罩
- 4. 降级方案:如果特定区域无法查询,尝试使用城市名称
故障排除
问题:未找到地点
- - 解决方案:尝试使用主要城市名称代替区域名称
- 示例:使用北京代替朝阳区
问题:无预报数据
- - 解决方案:确认地点名称是否正确
- 尝试标准城市名称:北京、上海、广州、深圳等
问题:数据似乎过时
- - 解决方案:API会定期更新,但天气变化迅速
- 检查响应中的updated时间戳
支持的地点
天气API支持中国大部分城市和区域,包括:
- - 省会城市:北京、上海、广州、深圳、成都、杭州、南京、武汉等
- 主要城市:苏州、青岛、大连、厦门等
- 区域:海淀区、朝阳区、浦东新区等