From c038be2b84f6105a076d6ada0bb32f604f063076 Mon Sep 17 00:00:00 2001 From: 114514 <2514624910@qq.com> Date: Fri, 9 May 2025 01:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=9B=AE=E5=89=8Dplanner=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=AE=A2=E8=A7=82=E5=86=B3=E7=AD=96=E7=9A=84=E5=89=8D?= =?UTF-8?q?=E6=8F=90=E4=B8=8B=20=E4=B8=8D=E5=86=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/PFC/action_planner.py | 36 +++++++++++++----------------- src/plugins/PFC/reply_generator.py | 20 ++++++++--------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/plugins/PFC/action_planner.py b/src/plugins/PFC/action_planner.py index 32faedc2..0a56d621 100644 --- a/src/plugins/PFC/action_planner.py +++ b/src/plugins/PFC/action_planner.py @@ -39,7 +39,6 @@ PROMPT_INITIAL_REPLY = """ 【最近的对话记录】(包括你已成功发送的消息 和 新收到的消息) {chat_history_text} -{spam_warning_info} ------ 可选行动类型以及解释: @@ -76,8 +75,6 @@ PROMPT_FOLLOW_UP = """ 【最近的对话记录】(包括你已成功发送的消息 和 新收到的消息) {chat_history_text} -{spam_warning_info} - ------ 可选行动类型以及解释: wait: 暂时不说话,留给对方交互空间,等待对方回复。 @@ -137,7 +134,6 @@ PROMPT_REFLECT_AND_ACT = """ 【最近的对话记录】(包括你已成功发送的消息 和 新收到的消息) {chat_history_text} -{spam_warning_info} ------ 可选行动类型以及解释: @@ -243,27 +239,27 @@ class ActionPlanner: log_msg = "使用 PROMPT_REFLECT_AND_ACT (反思决策)" # 对于 PROMPT_REFLECT_AND_ACT,它不包含 send_new_message 选项,所以 spam_warning_message 中的相关提示可以调整或省略 # 但为了保持占位符填充的一致性,我们仍然计算它 - spam_warning_message = "" - if conversation_info.my_message_count > 5: # 这里的 my_message_count 仍有意义,表示之前连续发送了多少 - spam_warning_message = ( - f"⚠️【警告】**你之前已连续发送{str(conversation_info.my_message_count)}条消息!请谨慎决策。**" - ) - elif conversation_info.my_message_count > 2: - spam_warning_message = f"💬【提示】**你之前已连续发送{str(conversation_info.my_message_count)}条消息。请注意保持对话平衡。**" + # spam_warning_message = "" + # if conversation_info.my_message_count > 5: # 这里的 my_message_count 仍有意义,表示之前连续发送了多少 + # spam_warning_message = ( + # f"⚠️【警告】**你之前已连续发送{str(conversation_info.my_message_count)}条消息!请谨慎决策。**" + # ) + # elif conversation_info.my_message_count > 2: + # spam_warning_message = f"💬【提示】**你之前已连续发送{str(conversation_info.my_message_count)}条消息。请注意保持对话平衡。**" elif last_successful_reply_action in ["direct_reply", "send_new_message"]: prompt_template = PROMPT_FOLLOW_UP log_msg = "使用 PROMPT_FOLLOW_UP (追问决策)" - spam_warning_message = "" - if conversation_info.my_message_count > 5: - spam_warning_message = f"⚠️【警告】**你已连续发送{str(conversation_info.my_message_count)}条消息!请注意不要再选择send_new_message!以免刷屏对造成对方困扰!**" - elif conversation_info.my_message_count > 2: - spam_warning_message = f"💬【警告】**你已连续发送{str(conversation_info.my_message_count)}条消息。请保持理智,如果非必要,请避免选择send_new_message,以免给对方造成困扰。**" + # spam_warning_message = "" + # if conversation_info.my_message_count > 5: + # spam_warning_message = f"⚠️【警告】**你已连续发送{str(conversation_info.my_message_count)}条消息!请注意不要再选择send_new_message!以免刷屏对造成对方困扰!**" + # elif conversation_info.my_message_count > 2: + # spam_warning_message = f"💬【警告】**你已连续发送{str(conversation_info.my_message_count)}条消息。请保持理智,如果非必要,请避免选择send_new_message,以免给对方造成困扰。**" else: prompt_template = PROMPT_INITIAL_REPLY log_msg = "使用 PROMPT_INITIAL_REPLY (首次/非连续回复决策)" - spam_warning_message = "" # 初始回复时通常不需要刷屏警告 + # spam_warning_message = "" # 初始回复时通常不需要刷屏警告 logger.debug(f"[私聊][{self.private_name}] {log_msg}") @@ -271,8 +267,8 @@ class ActionPlanner: if observation_info and hasattr(observation_info, "current_time_str") and observation_info.current_time_str: current_time_value = observation_info.current_time_str - if spam_warning_message: - spam_warning_message = f"\n{spam_warning_message}\n" + # if spam_warning_message: + # spam_warning_message = f"\n{spam_warning_message}\n" prompt = prompt_template.format( persona_text=persona_text, @@ -285,7 +281,7 @@ class ActionPlanner: # retrieved_memory_str=retrieved_memory_str if retrieved_memory_str else "无相关记忆。", # retrieved_knowledge_str=retrieved_knowledge_str if retrieved_knowledge_str else "无相关知识。", current_time_str=current_time_value, - spam_warning_info=spam_warning_message, + # spam_warning_info=spam_warning_message, sender_name=sender_name_str, relationship_text=relationship_text_str, current_emotion_text=current_emotion_text_str, diff --git a/src/plugins/PFC/reply_generator.py b/src/plugins/PFC/reply_generator.py index 5f3b3591..82abbb96 100644 --- a/src/plugins/PFC/reply_generator.py +++ b/src/plugins/PFC/reply_generator.py @@ -103,8 +103,6 @@ PROMPT_SEND_NEW_MESSAGE = """ {last_rejection_info} -{spam_warning_info} - 请根据上述信息,判断你是否要继续发一条新消息(例如对之前消息的补充,深入话题,或追问等等)。如果你觉得要发送,该消息应该: 1. 符合对话目标,以"你"的角度发言(不要自己与自己对话!) 2. 符合你的性格特征和身份细节 @@ -280,14 +278,14 @@ class ReplyGenerator: ) # 新增:构建刷屏警告信息 for PROMPT_SEND_NEW_MESSAGE - spam_warning_message = "" - if action_type == "send_new_message": # 只在 send_new_message 时构建刷屏警告 - if conversation_info.my_message_count > 5: - spam_warning_message = f"⚠️【警告】**你已连续发送{str(conversation_info.my_message_count)}条消息!请谨慎考虑是否继续发送!以免刷屏对造成对方困扰!**" - elif conversation_info.my_message_count > 2: - spam_warning_message = f"💬【提示】**你已连续发送{str(conversation_info.my_message_count)}条消息。如果非必要,请避免连续发送,以免给对方造成困扰。**" - if spam_warning_message: - spam_warning_message = f"\n{spam_warning_message}\n" + # spam_warning_message = "" + # if action_type == "send_new_message": # 只在 send_new_message 时构建刷屏警告 + # if conversation_info.my_message_count > 5: + # spam_warning_message = f"⚠️【警告】**你已连续发送{str(conversation_info.my_message_count)}条消息!请谨慎考虑是否继续发送!以免刷屏对造成对方困扰!**" + # elif conversation_info.my_message_count > 2: + # spam_warning_message = f"💬【提示】**你已连续发送{str(conversation_info.my_message_count)}条消息。如果非必要,请避免连续发送,以免给对方造成困扰。**" + # if spam_warning_message: + # spam_warning_message = f"\n{spam_warning_message}\n" # --- 选择 Prompt --- if action_type == "send_new_message": @@ -326,7 +324,7 @@ class ReplyGenerator: if action_type == "send_new_message": current_format_params = base_format_params.copy() - current_format_params["spam_warning_info"] = spam_warning_message + # current_format_params["spam_warning_info"] = spam_warning_message prompt = prompt_template.format(**current_format_params) elif action_type == "say_goodbye": farewell_params = {