From 073cc1a2de5439e0ec75c784dd0f14506a277d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Tue, 7 Jul 2026 15:47:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B3=A8=E5=85=A5=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E7=8A=B6=E6=80=81(A=E8=82=A1=E4=BA=A4=E6=98=93=E4=B8=AD/?= =?UTF-8?q?=E5=B7=B2=E6=94=B6=E7=9B=98=20=E6=B8=AF=E8=82=A1=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E4=B8=AD/=E5=B7=B2=E6=94=B6=E7=9B=98)=E9=98=B2?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E6=97=B6=E6=AE=B5=E5=B9=BB=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xmpp_agent_core.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/xmpp_agent_core.py b/xmpp_agent_core.py index d8ea6cc4..3cdb0e6e 100644 --- a/xmpp_agent_core.py +++ b/xmpp_agent_core.py @@ -186,9 +186,20 @@ class AgentBot(ClientXMPP): msg_type = 'groupchat' if is_group else 'chat' sid = session_id or SESSION_ID try: - # 注入当前日期时间,防止LLM日期幻觉 - now_str = datetime.now().strftime("%Y-%m-%d %H:%M %A") - timed_content = f"[当前时间: {now_str}]\n{content}" + # 注入当前时间 + 市场状态,防止LLM日期/交易时段幻觉 + now = datetime.datetime.now() + weekday = now.strftime("%A") + hour = now.hour + minute = now.minute + # 判断市场状态 + is_weekday = now.weekday() < 5 + if is_weekday: + ashare = "交易中" if (9 <= hour < 15) or (hour == 9 and minute >= 30) or (hour == 15 and minute == 0) else "已收盘" + hk = "交易中" if (9 <= hour < 16) or (hour == 9 and minute >= 30) or (hour == 15) else "已收盘" + else: + ashare = hk = "休市" + now_str = now.strftime("%Y-%m-%d %H:%M") + timed_content = f"[{now_str} {weekday} | A股{ashare} 港股{hk}]\n{content}" payload = json.dumps({ "model": "hermes-agent", "messages": [{"role": "user", "content": timed_content}]