From 84c89de827fc85361e22518629d9b119630f848e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 23 Jun 2025 07:37:04 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20=E8=87=AA=E5=8A=A8=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/official_configs.py | 2 -- src/plugins/built_in/core_actions/plugin.py | 40 +++++++++++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/config/official_configs.py b/src/config/official_configs.py index 1bf34d87e..333516f39 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -115,8 +115,6 @@ class NormalChatConfig(ConfigBase): willing_mode: str = "classical" """意愿模式""" - - response_interested_rate_amplifier: float = 1.0 """回复兴趣度放大系数""" diff --git a/src/plugins/built_in/core_actions/plugin.py b/src/plugins/built_in/core_actions/plugin.py index 0c5560ae0..e7a98d8bd 100644 --- a/src/plugins/built_in/core_actions/plugin.py +++ b/src/plugins/built_in/core_actions/plugin.py @@ -171,7 +171,7 @@ class NoReplyAction(BaseAction): last_judge_time = 0 # 上次进行LLM判断的时间 min_judge_interval = self._min_judge_interval # 最小判断间隔,从配置获取 check_interval = 0.2 # 检查新消息的间隔,设为0.2秒提高响应性 - + # 累积判断历史 judge_history = [] # 存储每次判断的结果和理由 @@ -275,12 +275,12 @@ class NoReplyAction(BaseAction): start_time=past_10min_time, end_time=current_time, ) - + # 手动过滤bot自己的消息 bot_message_count = 0 if all_messages_10min: user_id = global_config.bot.qq_account - + for message in all_messages_10min: # 检查消息发送者是否是bot sender_id = message.get("user_id", "") @@ -291,24 +291,30 @@ class NoReplyAction(BaseAction): print(bot_message_count) talk_frequency_threshold = global_config.chat.talk_frequency * 10 - + if bot_message_count > talk_frequency_threshold: over_count = bot_message_count - talk_frequency_threshold - + # 根据超过的数量设置不同的提示词 if over_count <= 5: frequency_block = "你感觉稍微有些累,回复的有点多了。\n" elif over_count <= 10: frequency_block = "你今天说话比较多,感觉有点疲惫,想要稍微休息一下。\n" elif over_count <= 20: - frequency_block = "你发现自己说话太多了,感觉很累,需要好好休息一下,不想频繁回复。\n" + frequency_block = ( + "你发现自己说话太多了,感觉很累,需要好好休息一下,不想频繁回复。\n" + ) else: frequency_block = "你感到非常疲惫,今天话说得太多了,想要安静一会儿,除非有重要的事情否则不想回复。\n" - - logger.info(f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,超过阈值{talk_frequency_threshold},添加疲惫提示") + + logger.info( + f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,超过阈值{talk_frequency_threshold},添加疲惫提示" + ) else: - logger.info(f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,未超过阈值{talk_frequency_threshold}") - + logger.info( + f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,未超过阈值{talk_frequency_threshold}" + ) + except Exception as e: logger.warning(f"{self.log_prefix} 检查发言频率时出错: {e}") frequency_block = "" @@ -378,17 +384,21 @@ class NoReplyAction(BaseAction): if judge_result == "需要回复": logger.info(f"{self.log_prefix} 模型判断需要回复,结束等待") - + # 构建包含判断历史的详细信息 history_summary = "" if len(judge_history) > 1: - history_summary = f"\n\n判断过程:\n" - for i, (timestamp, past_result, past_reason) in enumerate(judge_history[:-1], 1): + history_summary = "\n\n判断过程:\n" + for i, (timestamp, past_result, past_reason) in enumerate( + judge_history[:-1], 1 + ): elapsed_seconds = int(timestamp - start_time) history_summary += f"{i}. 等待{elapsed_seconds}秒时:{past_result},理由:{past_reason}\n" history_summary += f"{len(judge_history)}. 等待{elapsed_time:.0f}秒时:{judge_result},理由:{reason}" - - full_prompt = f"{global_config.bot.nickname}(你)的想法是:{reason}{history_summary}" + + full_prompt = ( + f"{global_config.bot.nickname}(你)的想法是:{reason}{history_summary}" + ) await self.store_action_info( action_build_into_prompt=True, action_prompt_display=full_prompt,