From 678b94000ca6c8a4d7401c48383ce9ed672a10fe Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sat, 23 May 2026 10:27:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=20AI=20prompt=20=E4=B8=BA?= =?UTF-8?q?=E7=BA=AF=E6=96=87=E6=9C=AC=E6=A0=BC=E5=BC=8F=EF=BC=8C=E9=99=8D?= =?UTF-8?q?=E4=BD=8E=20MiMo=20=E7=A9=BA=E5=93=8D=E5=BA=94=E6=A6=82?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/daily_weather_report.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/utils/daily_weather_report.py b/src/utils/daily_weather_report.py index 5e7672af..ef891260 100644 --- a/src/utils/daily_weather_report.py +++ b/src/utils/daily_weather_report.py @@ -2,7 +2,6 @@ from __future__ import annotations -import json import os import re import threading @@ -237,21 +236,12 @@ def _wmo_to_weather(code: Any) -> str: def _build_ai_prompt(cities_data: List[Dict[str, Any]], report_date: str) -> str: - data_json = json.dumps(cities_data, ensure_ascii=False, indent=2, default=str) - return ( - f"今天是 {report_date}。以下是今天中国主要城市的天气预报数据(JSON格式)," - "数据来自中国气象局(weather.com.cn)。\n\n" - f"{data_json}\n\n" - "请用自然亲切的中文写一段天气日报。每个城市逐行播报,格式:\n\n" - "城市名 weather,最高 forecast_high 度。一句话体感或穿衣建议。\n\n" - "要求:\n" - "1. weather 和 forecast_high 直接使用数据中的值,不要修改\n" - "2. 每城一行,城市名 加粗,换行用纯换行符,禁止用
标签\n" - "3. 只允许 两种 HTML 标签,其他标签一律禁止\n" - "4. 开头问候语「☀️ 早上好!今天是x月x日」\n" - "5. 播报完直接结束,禁止结尾祝福、总结、免责\n" - "6. 总字数不超过 200\n" - ) + lines = [f"今天是 {report_date}。请用自然亲切的中文写一段天气日报。\n"] + lines.append("城市天气数据:") + for c in cities_data: + lines.append(f"{c['name']}:{c['weather']},最高{c['forecast_high']}度") + lines.append("\n要求:每城一行播报,城市名加粗,开头问候,禁止结尾废话。") + return "\n".join(lines) def _call_ai(prompt: str) -> Optional[str]: @@ -273,8 +263,8 @@ def _call_ai(prompt: str) -> Optional[str]: "messages": [ {"role": "user", "content": prompt}, ], - "max_tokens": 1200, - "temperature": 0.7, + "max_tokens": 800, + "temperature": 0.5, } timeout = httpx.Timeout(timeout=30.0, connect=8.0, read=30.0)