Fix agent temporal perception error by adding current real-world time to LLM prompt.

This commit is contained in:
lintsinghua
2025-11-04 01:41:21 +08:00
committed by BaiFu
parent e1c201afc9
commit 66af69d958
4 changed files with 28 additions and 0 deletions
+7
View File
@@ -211,6 +211,13 @@ class ForumHost:
def _call_qwen_api(self, system_prompt: str, user_prompt: str) -> Dict[str, Any]:
"""调用Qwen API"""
try:
current_time = datetime.now().strftime("%Y年%m月%d%H时%M分")
time_prefix = f"今天的实际时间是{current_time}"
if user_prompt:
user_prompt = f"{time_prefix}\n{user_prompt}"
else:
user_prompt = time_prefix
response = self.client.chat.completions.create(
model=self.model,
messages=[