Weather Outfit Advisor
Overview
Provides personalized outfit recommendations based on real-time weather data for your destination and your personal clothing preferences.
Workflow
Step 1: Check Information Completeness
Before providing recommendations, must confirm the following three key pieces of information:
- 1. Destination (city name)
- Date (specific date or date range)
- Clothing Preferences (style preference, temperature sensitivity, special needs, etc.)
Information Extraction Strategy:
- - Extract explicit destination, date, and preferences from user input
- Recognize relative date terms ("tomorrow", "day after tomorrow", "next Monday", etc.) and convert to specific dates
- If any item is missing, must ask the user first
Relative Date Conversion Rules:
- - "tomorrow" → current date + 1 day
- "day after tomorrow" → current date + 2 days
- "three days later" → current date + 3 days
- "next Monday" → next Monday's date
- "this weekend" → this Saturday or Sunday (needs confirmation)
Example:
CODEBLOCK0
Step 2: Collect Necessary Information
Adopt different clarification strategies based on the number of missing items:
Strategy A: Missing Only 1 Item (Targeted Question)
Ask only about the missing item:
If only missing clothing preferences:
CODEBLOCK1
If only missing date:
CODEBLOCK2
If only missing destination:
CODEBLOCK3
Strategy B: Missing 2-3 Items (Ask All at Once)
When multiple items are missing, list all questions at once:
CODEBLOCK4
Relative Date Handling
When users use relative dates:
Recognize Keywords:
- - tomorrow, day after tomorrow, three days later
- next Monday, next Tuesday... next Sunday
- this weekend, next weekend
- next week, next month
Conversion Logic:
- 1. Get current system date
- Calculate specific date based on relative term
- Confirm the converted date in the response
Example:
CODEBLOCK5
Step 3: Query Weather Data
Use the provided Python script (recommended):
CODEBLOCK6
Script Features:
- - ✅ Automatic relative date parsing (tomorrow, day after tomorrow, next Monday, etc.)
- ✅ City name normalization (supports Chinese/English and common aliases)
- ✅ Calls wttr.in API to get weather data
- ✅ Returns structured JSON data
- ✅ Includes current weather and forecast information
Output Example (JSON format):
CODEBLOCK7
Extract Key Information from Output:
CODEBLOCK8
Alternative: Direct API Call (if script is unavailable):
Current Weather API:
CODEBLOCK9
Example:
CODEBLOCK10
Parse JSON Response for Key Information:
CODEBLOCK11
Alternative: OpenWeatherMap API (requires free API key):
If wttr.in is unavailable, you can use OpenWeatherMap:
API Endpoint:
CODEBLOCK12
Forecast API:
CODEBLOCK13
Note:
- -
{API_KEY} needs to be requested from https://openweathermap.org/api (free version is sufficient) - INLINECODE1 uses Celsius
- INLINECODE2 returns English description
Step 4: Analyze Weather Data
Extract key information from the API response:
CODEBLOCK14
Step 5: Generate Outfit Recommendations
Generate recommendations based on weather data and user preferences:
Temperature Range Reference
| Temperature Range | Outfit Recommendation |
|---|
| < 5°C | Heavy down jacket, thermal underwear, sweater, scarf, gloves, hat |
| 5-10°C |
Thick coat, padded jacket, knitwear, thin sweater |
| 10-15°C | Trench coat, jacket, hoodie, long-sleeve T-shirt |
| 15-20°C | Light jacket, denim jacket, long-sleeve shirt, T-shirt + cardigan |
| 20-25°C | Long-sleeve T-shirt, thin shirt, single layer clothing |
| 25-30°C | Short-sleeve T-shirt, shirt, skirt, shorts |
| > 30°C | Breathable short-sleeve, tank top, sun protection clothing, sun hat |
Consider Other Factors
Rainy Days:
- - Carry umbrella or raincoat
- Choose waterproof shoes
- Avoid light-colored clothing
Windy Days:
- - Avoid skirts or choose anti-exposure styles
- Wear windproof jacket
- Secure hat properly
High Humidity:
- - Choose breathable quick-dry fabrics
- Avoid heavy clothing
Strong UV:
- - Apply sunscreen
- Wear sunglasses
- Wear sun protection clothing or long sleeves
Add Image Reference (Optional but Recommended)
After providing outfit recommendations, call the image search script to provide visual references:
CODEBLOCK15
Examples:
CODEBLOCK16
Step 6: Output Format
Output recommendations in the following format:
CODEBLOCK17
Special Cases Handling
API Call Failure
If API call fails or returns error:
CODEBLOCK18
Extreme Weather Warning
If extreme weather is detected (typhoon, blizzard, heavy rain warning, etc.):
CODEBLOCK19
Multi-Day Trip
If user provides a date range:
CODEBLOCK20
Personalization Adjustments
Adjust recommendations based on user's clothing habits:
Cold-sensitive users: Recommend adding extra warm layers to base outfit
Heat-sensitive users: Recommend more breathable fabrics, reduce layers
Business needs: Maintain professional appearance while ensuring comfort
Outdoor sports: Prioritize functional clothing (quick-dry, waterproof, windproof)
Pregnant/elderly/children: Pay extra attention to warmth and comfort
Example Dialogues
Example 1: Complete Information
User: I'm going to Hangzhou tomorrow, I'm usually sensitive to cold, prefer casual style.
Assistant: Step 1: Query weather
CODEBLOCK21
Step 2: Parse data
Extract from returned JSON:
- - Temperature range: 11-21°C
- Weather condition: Patchy rain nearby
- Humidity: 56%
- Rain chance: 70%
Step 3: Generate recommendations
According to weather forecast, Hangzhou tomorrow:
- - Temperature: 11-21°C
- Weather: Patchy rain nearby
- Humidity: 56%
Outfit recommendations:
- - Top: Long-sleeve T-shirt + knit cardigan + thin trench coat (considering you're sensitive to cold, recommend bringing thermal underwear as backup)
- Bottom: Jeans or casual pants
- Shoes: Sneakers or casual shoes
- Accessories: Can bring a thin scarf, umbrella
Example 2: Incomplete Information
User: I'm going out to play in a few days, how should I dress?
Assistant: To provide you with the most suitable outfit recommendations, I need some information:
- 1. What is your travel destination?
- When exactly are you traveling?
- What are your usual clothing habits? Any special preferences (such as sensitive to cold/heat, prefer casual/business style, etc.)?
Example 3: Real Call Case
User: I'm going to Hangzhou tomorrow, I'm quite heat-sensitive
Assistant: Execution Flow:
- 1. Information Extraction:
- Destination: Hangzhou ✓
- Date: tomorrow (relative date) → convert to specific date
- Clothing preferences: heat-sensitive ✓
- 2. Date Conversion:
- Get current system date: 2026-04-01
- Calculate: tomorrow = 2026-04-02
- Confirm: "Sure, I'll check the weather for Hangzhou tomorrow (April 2nd)"
- 3. Use wttr.in API to query Hangzhou weather: INLINECODE3
- 4. Parse JSON to get data:
- Current temperature: 19°C
- Max temp: 21°C, Min temp: 11°C
- Weather: Patchy rain nearby
- Humidity: 56%
- 5. Adjust recommendations based on heat-sensitive preference
Then output complete outfit recommendations...
Example 4: Boundary Case Testing
Scenario A: Seriously Insufficient Information
User: How should I dress?
Assistant: To provide you with the most suitable outfit recommendations, I need some information:
- 1. What is your travel destination?
- When exactly are you traveling? (You can say "tomorrow", "April 5th", etc.)
- What are your usual clothing habits? (For example, sensitive to cold/heat, preferred style, etc.)
Scenario B: Only Partial Information
User: I'm going to Shanghai the day after tomorrow
Assistant: Sure, I'll help you check the weather for Shanghai the day after tomorrow.
To make the recommendation more suitable for you, please tell me about your clothing preferences:
- - Are you usually sensitive to cold or heat?
- What style do you prefer? (casual/business/sports, etc.)
- Any special needs? (such as formal occasions, outdoor activities, etc.)
(Wait for user response, then query weather and provide complete recommendations)
Scenario C: Multi-Day Trip
User: I'm going to Beijing on business from next Monday to Friday, I'm sensitive to cold
Assistant: Execution Flow:
- 1. Recognize this is a date range: next Monday to Friday (total 5 days)
- Query weather forecast for each of the 5 days separately
- Provide daily outfit recommendations
- Give overall suggestions for clothing packing list (considering laundry and matching)
Output format:
CODEBLOCK22
Example 5: Special Cases Handling
Extreme Weather Warning
If extreme weather is detected (typhoon, heavy rain red warning, etc.):
CODEBLOCK23
API Call Failure
If API call fails or returns error:
CODEBLOCK24
Prompt Optimization
When actually using, can add the following prompt optimization suggestions based on situation:
- - Remind users that areas with large temperature differences between morning and evening need "onion-style" dressing
- Suggest bringing easy-to-match items to deal with weather changes
- Recommend practical layering combinations
- Consider luggage space limitations, suggest versatile items
Appendix: Script Usage Instructions
get_weather.py Script
Location: INLINECODE4
Features:
- 1. ✅ Supports Chinese/English city names
- ✅ Automatic relative date parsing (tomorrow, day after tomorrow, next Monday, etc.)
- ✅ City name normalization (e.g., "Beijing" → "Beijing")
- ✅ Returns structured JSON data
- ✅ Includes current weather and forecast information
- ✅ No API key required (uses wttr.in free service)
Usage:
CODEBLOCK25
Output Format:
- - stdout: JSON format weather data (for program processing)
- stderr: Human-readable formatted output (for direct viewing)
JSON Data Structure:
CODEBLOCK26
Error Handling:
If query fails, returns:
CODEBLOCK27
Dependencies:
- - Python 3.6+
- Standard library:
sys, json, urllib.request, INLINECODE8 - No additional third-party libraries required
search_images.py Script
Location: INLINECODE9
Features:
- 1. ✅ Searches fashion/outfit images related to destination
- ✅ Supports multiple image APIs (Pexels, Pixabay, etc.)
- ✅ Returns structured image information (URL, photographer, dimensions, etc.)
- ✅ Automatically generates optimized search keywords
- ✅ Provides manual search alternative
Supported APIs:
| API | Requires Key | Free Quota | Recommendation |
|---|
| Pexels | ✅ Yes | 20,000/month | ⭐⭐⭐⭐⭐ |
| Pixabay |
✅ Yes | 500/day | ⭐⭐⭐⭐ |
| Bing Search | ❌ No | Limited | ⭐⭐⭐ |
Usage:
CODEBLOCK28
Output Format:
- - stdout: JSON format image list (for program processing)
- stderr: Human-readable formatted output (for viewing)
JSON Data Structure:
CODEBLOCK29
Smart Keyword Generation:
Script automatically generates optimized search terms based on city context:
- -
{city} street style fashion - Street style - INLINECODE11 - Outfit inspiration
- INLINECODE12 - Casual outfits
- INLINECODE13 - Travel outfits
API Key Configuration:
Recommend using Pexels API (highest quality):
- 1. Apply for free API key: https://www.pexels.com/api/
- Set in script:
CODEBLOCK30
- 3. Or via environment variable:
CODEBLOCK31
Fallback Strategy:
If API key is not configured, script will:
- 1. Provide manual search link
- List available API options
- User can visit search link to view images manually
Usage Scenario:
Add image references in outfit recommendations:
CODEBLOCK32
Notes:
- - Image copyright belongs to original photographer
- For personal reference only, not for commercial use
- Respect photographers' work
- Recommend using high-quality image API for better experience
天气穿搭顾问
概述
根据目的地的实时天气数据和个人穿衣偏好,提供个性化的穿搭建议。
工作流程
第一步:检查信息完整性
在提供建议之前,必须确认以下三项关键信息:
- 1. 目的地(城市名称)
- 日期(具体日期或日期范围)
- 穿衣偏好(风格偏好、对温度的敏感程度、特殊需求等)
信息提取策略:
- - 从用户输入中提取明确的目的地、日期和偏好
- 识别相对日期术语(明天、后天、下周一等)并转换为具体日期
- 如果缺少任何一项,必须先询问用户
相对日期转换规则:
- - 明天 → 当前日期 + 1天
- 后天 → 当前日期 + 2天
- 三天后 → 当前日期 + 3天
- 下周一 → 下一个周一的日期
- 这周末 → 本周六或周日(需要确认)
示例:
用户:我明天要去杭州
→ 提取:目的地 = 杭州,日期 = 明天
→ 转换:获取当前日期(例如 2026-04-01),计算明天 = 2026-04-02
→ 缺失:穿衣偏好
→ 操作:询问穿衣偏好
第二步:收集必要信息
根据缺失信息的数量采取不同的询问策略:
策略A:仅缺失1项(针对性提问)
仅询问缺失项:
如果仅缺失穿衣偏好:
好的,我来帮您查询[城市]在[日期]的天气。
为了让推荐更适合您,请告诉我您的穿衣偏好:
- - 您平时怕冷还是怕热?
- 喜欢什么风格?(休闲/商务/运动等)
- 有什么特殊需求吗?(如正式场合、户外活动等)
如果仅缺失日期:
您计划什么时候出行?(请提供具体日期,或说明天、后天等)
如果仅缺失目的地:
您的出行目的地是哪里?(请提供城市名称)
策略B:缺失2-3项(一次性询问)
当多项信息缺失时,一次性列出所有问题:
为了给您提供最合适的穿搭建议,我需要了解一些信息:
- 1. 您的出行目的地是哪里?
- 具体什么时间出行?(可以说明天、4月5日等)
- 您平时的穿衣习惯是怎样的?(比如怕冷/怕热、偏好的风格等)
相对日期处理
当用户使用相对日期时:
识别关键词:
- - 明天、后天、三天后
- 下周一、下周二……下周日
- 这周末、下周末
- 下周、下个月
转换逻辑:
- 1. 获取当前系统日期
- 根据相对术语计算具体日期
- 在回复中确认转换后的日期
示例:
用户:我明天要去杭州
→ 系统获取当前日期:2026-04-01
→ 计算:明天 = 2026-04-02
→ 回复确认:好的,我来查询杭州明天(4月2日)的天气……
第三步:查询天气数据
使用提供的Python脚本(推荐):
bash
基本用法
python scripts/get_weather.py <城市> [日期]
示例
python scripts/get_weather.py 杭州 2026-04-02
python scripts/get_weather.py 北京 明天
python scripts/get_weather.py 上海 明天
脚本特性:
- - ✅ 自动解析相对日期(明天、后天、下周一等)
- ✅ 城市名称规范化(支持中英文及常见别名)
- ✅ 调用wttr.in API获取天气数据
- ✅ 返回结构化JSON数据
- ✅ 包含当前天气和预报信息
输出示例(JSON格式):
json
{
success: true,
city: Hangzhou,
query_date: 2026-04-01,
target_date: 2026-04-02,
current: {
temp_c: 19,
feelslikec: 19,
humidity: 56,
weather_desc: 附近有零星小雨,
windspeedkmph: 6,
uv_index: 5
},
forecast: {
maxtempc: 21,
mintempc: 11,
avg_humidity: 60,
dailychanceof_rain: 70,
weather_desc: 小毛毛雨
}
}
从输出中提取关键信息:
python
import json
假设weather_data是脚本返回的JSON数据
current = weather_data[current]
forecast = weather_data[forecast]
temperaturerange = f{forecast[mintempc]}-{forecast[maxtemp_c]}°C
weathercondition = forecast[weatherdesc]
humidity = current[humidity]
rainchance = forecast[dailychanceofrain]
备选方案:直接调用API(如果脚本不可用):
当前天气API:
https://wttr.in/{城市}?format=j1
示例:
bash
curl https://wttr.in/Hangzhou?format=j1
解析JSON响应获取关键信息:
python
import json
当前天气
current = data[current_condition][0]
temperature = current[temp_C] # 摄氏度
feels_like = current[FeelsLikeC] # 体感温度
humidity = current[humidity] # 湿度
weather_desc = current[weatherDesc][0][value] # 天气描述
wind_speed = current[windspeedKmph] # 风速
天气预报
forecast = data[weather][0]
max_temp = forecast[maxtempC] # 最高温度
min_temp = forecast[mintempC] # 最低温度
备选方案:OpenWeatherMap API(需要免费API密钥):
如果wttr.in不可用,可以使用OpenWeatherMap:
API端点:
https://api.openweathermap.org/data/2.5/weather?q={城市}&appid={APIKEY}&units=metric&lang=zhcn
预报API:
https://api.openweathermap.org/data/2.5/forecast?q={城市}&appid={APIKEY}&units=metric&lang=zhcn
注意:
- - {APIKEY} 需要从 https://openweathermap.org/api 申请(免费版即可)
- units=metric 使用摄氏度
- lang=zhcn 返回中文描述
第四步:分析天气数据
从API响应中提取关键信息:
json
{
main: {
temp: 25, // 当前温度
feels_like: 27, // 体感温度
humidity: 60 // 湿度
},
weather: [
{
description: 晴, // 天气状况
main: Clear
}
],
wind: {
speed: 3.5 // 风速
}
}
第五步:生成穿搭建议
根据天气数据和用户偏好生成建议:
温度范围参考
| 温度范围 | 穿搭建议 |
|---|
| < 5°C | 厚羽绒服、保暖内衣、毛衣、围巾、手套、帽子 |
| 5-10°C |
厚外套、棉服、针织衫、薄毛衣 |
| 10-15°C | 风衣、夹克、连帽衫、长袖T恤 |
| 15-20°C | 薄外套、牛仔外套、长袖衬衫、T恤+开衫 |
| 20-25°C | 长袖T恤、薄衬衫、单层衣物 |
| 25-30°C | 短袖T恤、衬衫、裙子、短裤 |
| > 30°C | 透气短袖、背心、防晒衣、遮阳帽 |
考虑其他因素
雨天:
大风天:
- - 避免裙子或选择防走光款式
- 穿防风外套
- 帽子要固定好
高湿度:
强紫外线:
添加图片参考(可选但推荐)
在提供穿搭建议后,调用图片搜索脚本提供视觉参考:
bash
搜索城市街拍风格
python scripts/search_images.py {城市} 街拍时尚 5
搜索季节性穿搭
python scripts/search_images.py {城市} {季节} 穿搭 5
搜索特定场合穿搭
python scripts/search_images.py {城市