generateWeatherOutfitPrompt static method
生成天气搭配提示词
Implementation
static Future<String> generateWeatherOutfitPrompt({
String city = '北京',
}) async {
final today = await getCurrentWeather(city: city);
final tomorrow = await getTomorrowWeather(city: city);
if (today == null && tomorrow == null) {
return '';
}
StringBuffer prompt = StringBuffer();
prompt.writeln('\n【天气信息】');
if (today != null) {
prompt.writeln('今天:${today.weatherEmoji} ${today.condition},温度${today.temperature}°C');
prompt.writeln(today.dressingSuggestion);
if (today.needsUmbrella) {
prompt.writeln('⚠️ 记得带伞');
}
}
if (tomorrow != null) {
prompt.writeln('\n明天:${tomorrow.weatherEmoji} ${tomorrow.condition},温度${tomorrow.minTemp}~${tomorrow.maxTemp}°C');
if (tomorrow.temperature - (today?.temperature ?? 20) > 5) {
prompt.writeln('⚠️ 明天升温,可以穿得清凉一些');
} else if ((today?.temperature ?? 20) - tomorrow.temperature > 5) {
prompt.writeln('⚠️ 明天降温,注意保暖');
}
if (tomorrow.needsUmbrella) {
prompt.writeln('⚠️ 明天有雨,建议带伞');
}
}
prompt.writeln('\n请根据天气情况,从用户虚拟衣橱中推荐合适的搭配。');
return prompt.toString();
}