asemxin commited on
Commit ·
c45a150
1
Parent(s): 9c6b42a
fix: 系统时间注入 system prompt,修复日期幻觉
Browse files- image_daemon.py +4 -1
image_daemon.py
CHANGED
|
@@ -387,8 +387,11 @@ def chat_with_llm(user_text, history=None):
|
|
| 387 |
|
| 388 |
import json as _json
|
| 389 |
soul = _soul_prompt or "You are a helpful assistant."
|
|
|
|
|
|
|
| 390 |
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
|
| 391 |
-
messages = [{"role": "system", "content":
|
|
|
|
| 392 |
|
| 393 |
for _ in range(4): # 最多 3 次工具调用 + 1 次最终回复
|
| 394 |
log(f"🤖 外部 LLM ({MODEL_NAME}): {user_text[:50]}...")
|
|
|
|
| 387 |
|
| 388 |
import json as _json
|
| 389 |
soul = _soul_prompt or "You are a helpful assistant."
|
| 390 |
+
now_str = time.strftime("%Y-%m-%d %H:%M:%S %Z")
|
| 391 |
+
dated_soul = f"[当前系统时间: {now_str}]\n\n{soul}"
|
| 392 |
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
|
| 393 |
+
messages = [{"role": "system", "content": dated_soul}] + (history or []) + [{"role": "user", "content": user_text}]
|
| 394 |
+
|
| 395 |
|
| 396 |
for _ in range(4): # 最多 3 次工具调用 + 1 次最终回复
|
| 397 |
log(f"🤖 外部 LLM ({MODEL_NAME}): {user_text[:50]}...")
|