From cbde6208d3754f062985deb71fcd74ccc6607eaa Mon Sep 17 00:00:00 2001 From: tt-P607 <68868379+tt-P607@users.noreply.github.com> Date: Sat, 1 Nov 2025 20:55:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(proactive-chatter):=20=E4=B8=BA=E6=89=80?= =?UTF-8?q?=E6=9C=89=E4=B8=BB=E5=8A=A8=E4=BA=A4=E4=BA=92=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E7=BB=9F=E4=B8=80=E7=9A=84=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正了 `simple_bubble_reply` 提示中缺失时间信息的问题。此前的疏忽可能导致模型在不了解当前时间的情况下生成回复。 为确保一致性并修复此问题,引入了一个通用的 `time_block` 变量。该变量现在被系统性地添加到所有主动思考流程的提示(决策、抛话题、简单回复)中,确保模型在进行任何主动交互时都能获得准确的时间锚点,从而提高其响应的恰当性。 --- .../proactive_thinking_executor.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/plugins/built_in/affinity_flow_chatter/proactive_thinking_executor.py b/src/plugins/built_in/affinity_flow_chatter/proactive_thinking_executor.py index 7c3f11bb6..7a5207bc7 100644 --- a/src/plugins/built_in/affinity_flow_chatter/proactive_thinking_executor.py +++ b/src/plugins/built_in/affinity_flow_chatter/proactive_thinking_executor.py @@ -29,10 +29,11 @@ logger = get_logger("proactive_thinking_executor") # 决策 Prompt decision_prompt_template = Prompt( - """你的人设是: + """{time_block} +你的人设是: {bot_personality} -现在是 {current_time},你正在考虑是否要在与 "{stream_name}" 的对话中主动说些什么。 +你正在考虑是否要在与 "{stream_name}" 的对话中主动说些什么。 【你当前的心情】 {current_mood} @@ -84,7 +85,8 @@ decision_prompt_template = Prompt( # 冒泡回复 Prompt simple_bubble_reply_prompt_template = Prompt( - """你的人设是: + """{time_block} +你的人设是: {bot_personality} 距离上次对话已经有一段时间了,你决定主动说些什么,轻松地开启新的互动。 @@ -113,10 +115,11 @@ simple_bubble_reply_prompt_template = Prompt( # 抛出话题回复 Prompt throw_topic_reply_prompt_template = Prompt( - """你的人设是: + """{time_block} +你的人设是: {bot_personality} -现在是 {current_time},你决定在与 "{stream_name}" 的对话中主动发起一次互动。 +你决定在与 "{stream_name}" 的对话中主动发起一次互动。 【你当前的心情】 {current_mood} @@ -202,9 +205,12 @@ class ProactiveThinkingPlanner: if recent_messages: recent_chat_history = await message_api.build_readable_messages_to_str(recent_messages) - # 3. 获取bot人设 + # 3. 获取bot人设和时间信息 individuality = Individuality() bot_personality = await individuality.get_personality_block() + + # 构建时间信息块 + time_block = f"当前时间是 {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}" # 4. 获取当前心情 current_mood = "感觉很平静" # 默认心情 @@ -242,7 +248,7 @@ class ProactiveThinkingPlanner: "interest_score": stream_data.get("stream_interest_score", 0.5), "recent_chat_history": recent_chat_history or "暂无最近聊天记录", "bot_personality": bot_personality, - "current_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), + "time_block": time_block, "current_mood": current_mood, "last_decision": last_decision, } @@ -315,8 +321,8 @@ class ProactiveThinkingPlanner: last_decision_text += f"\n- 话题: {last_topic}" decision_prompt = decision_prompt_template.format( + time_block=context["time_block"], bot_personality=context["bot_personality"], - current_time=context["current_time"], stream_name=context["stream_name"], current_mood=context.get("current_mood", "感觉很平静"), stream_impression=context["stream_impression"], @@ -378,6 +384,7 @@ class ProactiveThinkingPlanner: if action == "simple_bubble": reply_prompt = simple_bubble_reply_prompt_template.format( + time_block=context["time_block"], bot_personality=context["bot_personality"], current_mood=context.get("current_mood", "感觉很平静"), stream_impression=context["stream_impression"], @@ -387,8 +394,8 @@ class ProactiveThinkingPlanner: ) else: # throw_topic reply_prompt = throw_topic_reply_prompt_template.format( + time_block=context["time_block"], bot_personality=context["bot_personality"], - current_time=context["current_time"], stream_name=context["stream_name"], current_mood=context.get("current_mood", "感觉很平静"), stream_impression=context["stream_impression"],