From 517222166b4b77a815595d3bf7b159c32aef5518 Mon Sep 17 00:00:00 2001 From: Bakadax Date: Tue, 6 May 2025 20:12:07 +0800 Subject: [PATCH] =?UTF-8?q?pfc=20action=20prompt=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3=E7=A7=81=E8=81=8A?= =?UTF-8?q?=E5=88=B7=E5=B1=8F=E9=97=AE=E9=A2=98=EF=BC=88action=EF=BC=9A=20?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E8=BF=99=E7=A7=8D=E4=B8=9C=E8=A5=BF=E4=B8=BA?= =?UTF-8?q?=E4=BB=80=E4=B9=88=E8=A6=81=E8=AE=A9=E6=88=91=E6=9D=A5=EF=BC=9F?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=87=8C=E5=86=99=E6=AD=BB=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E6=9B=B4=E5=87=86=E7=A1=AE=E5=90=97=EF=BC=9F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/PFC/action_planner.py | 5 ++++- src/plugins/PFC/conversation.py | 3 +++ src/plugins/PFC/conversation_info.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/PFC/action_planner.py b/src/plugins/PFC/action_planner.py index 96b1630c..21ffbef6 100644 --- a/src/plugins/PFC/action_planner.py +++ b/src/plugins/PFC/action_planner.py @@ -86,7 +86,7 @@ block_and_ignore: 更加极端的结束对话方式,直接结束对话并在 请以JSON格式输出你的决策: {{ "action": "选择的行动类型 (必须是上面列表中的一个)", - "reason": "选择该行动的详细原因 (必须有解释你是如何根据“上一次行动结果”、“对话记录”和自身设定人设做出合理判断的。请说明你为什么选择继续发言而不是等待,以及打算发送什么类型的新消息连续发言,必须记录已经发言了几次)" + "reason": "选择该行动的详细原因 (必须有解释你是如何根据“上一次行动结果”、“对话记录”和自身设定人设做出合理判断的。)" }} 注意:请严格按照JSON格式输出,不要包含任何其他内容。""" @@ -197,6 +197,9 @@ 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 conversation_info.my_message_count > 2: + current_time_value += f"\n你已连续发送{str(conversation_info.my_message_count)},如果没有必要请不要连续发送大量消息,以免形成刷屏造成对方困扰。" + prompt = prompt_template.format( persona_text=persona_text, goals_str=goals_str if goals_str.strip() else "- 目前没有明确对话目标,请考虑设定一个。", diff --git a/src/plugins/PFC/conversation.py b/src/plugins/PFC/conversation.py index d4ba017c..ad9b5281 100644 --- a/src/plugins/PFC/conversation.py +++ b/src/plugins/PFC/conversation.py @@ -799,6 +799,7 @@ class Conversation: f"[私聊][{self.private_name}] 因规划期间收到 {other_new_msg_count_during_planning} 条他人新消息,下一轮强制使用【初始回复】逻辑。" ) conversation_info.last_successful_reply_action = None # 强制初始回复 + conversation_info.my_message_count = 0 # 自身发言数量清零 else: # 规则:如果规划期间【没有】收到他人新消息,则允许追问 logger.info( @@ -1061,6 +1062,8 @@ class Conversation: content=reply_content, reply_to_message=None, # 私聊通常不需要引用回复 ) + # 自身发言数量累计 +1 + self.conversation_info.my_message_count += 1 # 发送成功后,将状态设置回分析,准备下一轮规划 self.state = ConversationState.ANALYZING return True # 返回成功 diff --git a/src/plugins/PFC/conversation_info.py b/src/plugins/PFC/conversation_info.py index 062a4641..618760f0 100644 --- a/src/plugins/PFC/conversation_info.py +++ b/src/plugins/PFC/conversation_info.py @@ -10,3 +10,4 @@ class ConversationInfo: self.last_successful_reply_action: Optional[str] = None self.last_reply_rejection_reason: Optional[str] = None # 用于存储上次回复被拒原因 self.last_rejected_reply_content: Optional[str] = None # 用于存储上次被拒的回复内容 + self.my_message_count: int = 0 # 用于存储连续发送了多少条消息 \ No newline at end of file