From 4b59eda5c0e2c1296bb11362849e552c04fbe8c6 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Mon, 11 Aug 2025 01:17:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9focus=20value=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E9=80=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/chat_loop/heartFC_chat.py | 43 +++++++++++++----------------- template/bot_config_template.toml | 10 +++---- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/chat/chat_loop/heartFC_chat.py b/src/chat/chat_loop/heartFC_chat.py index c39e593ed..f416bcecb 100644 --- a/src/chat/chat_loop/heartFC_chat.py +++ b/src/chat/chat_loop/heartFC_chat.py @@ -251,21 +251,23 @@ class HeartFChatting: new_message_count = len(new_message) - talk_frequency = global_config.chat.get_current_talk_frequency(self.stream_id) - modified_exit_count_threshold = self.focus_energy / talk_frequency + # talk_frequency = global_config.chat.get_current_talk_frequency(self.stream_id) + modified_exit_count_threshold = self.focus_energy / global_config.chat.focus_value + + total_interest = 0.0 + for msg_dict in new_message: + interest_value = msg_dict.get("interest_value", 0.0) + if msg_dict.get("processed_plain_text", ""): + total_interest += interest_value if new_message_count >= modified_exit_count_threshold: # 记录兴趣度到列表 - total_interest = 0.0 - for msg_dict in new_message: - interest_value = msg_dict.get("interest_value", 0.0) - if msg_dict.get("processed_plain_text", ""): - total_interest += interest_value + self.recent_interest_records.append(total_interest) logger.info( - f"{self.log_prefix} 累计消息数量达到{new_message_count}条(>{modified_exit_count_threshold}),结束等待" + f"{self.log_prefix} 累计消息数量达到{new_message_count}条(>{modified_exit_count_threshold:.1f}),结束等待" ) logger.info(self.last_read_time) logger.info(new_message) @@ -273,31 +275,24 @@ class HeartFChatting: # 检查累计兴趣值 if new_message_count > 0: - accumulated_interest = 0.0 - for msg_dict in new_message: - text = msg_dict.get("processed_plain_text", "") - interest_value = msg_dict.get("interest_value", 0.0) - if text: - accumulated_interest += interest_value - # 只在兴趣值变化时输出log - if not hasattr(self, "_last_accumulated_interest") or accumulated_interest != self._last_accumulated_interest: - logger.info(f"{self.log_prefix} breaking形式当前累计兴趣值: {accumulated_interest:.2f}, 当前聊天频率: {talk_frequency:.2f}") - self._last_accumulated_interest = accumulated_interest + if not hasattr(self, "_last_accumulated_interest") or total_interest != self._last_accumulated_interest: + logger.info(f"{self.log_prefix} breaking形式当前累计兴趣值: {total_interest:.2f}, 专注度: {global_config.chat.focus_value:.1f}") + self._last_accumulated_interest = total_interest - if accumulated_interest >= 3 / talk_frequency: + if total_interest >= 3 / global_config.chat.focus_value: # 记录兴趣度到列表 - self.recent_interest_records.append(accumulated_interest) + self.recent_interest_records.append(total_interest) logger.info( - f"{self.log_prefix} 累计兴趣值达到{accumulated_interest:.2f}(>{5 / talk_frequency}),结束等待" + f"{self.log_prefix} 累计兴趣值达到{total_interest:.2f}(>{3 / global_config.chat.focus_value}),结束等待" ) - return True,accumulated_interest/new_message_count + return True,total_interest/new_message_count # 每10秒输出一次等待状态 if int(time.time() - self.last_read_time) > 0 and int(time.time() - self.last_read_time) % 10 == 0: logger.info( - f"{self.log_prefix} 已等待{time.time() - self.last_read_time:.0f}秒,累计{new_message_count}条消息,继续等待..." + f"{self.log_prefix} 已等待{time.time() - self.last_read_time:.0f}秒,累计{new_message_count}条消息,累计兴趣{total_interest:.1f},继续等待..." ) await asyncio.sleep(0.5) @@ -423,7 +418,7 @@ class HeartFChatting: x0 = 1.0 # 控制曲线中心点 return 1.0 / (1.0 + math.exp(-k * (interest_val - x0))) - normal_mode_probability = calculate_normal_mode_probability(interest_value) + normal_mode_probability = calculate_normal_mode_probability(interest_value) / global_config.chat.get_current_talk_frequency(self.stream_id) # 根据概率决定使用哪种模式 if random.random() < normal_mode_probability: diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 626d552f0..abdb18f6e 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "6.2.2" +version = "6.3.0" #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- #如果你想要修改配置文件,请递增version的值 @@ -54,11 +54,11 @@ expression_groups = [ [chat] #麦麦的聊天通用设置 -focus_value = 1 -# 麦麦的专注思考能力,越高越容易专注,可能消耗更多token -# 专注时能更好把握发言时机,能够进行持久的连续对话 +talk_frequency = 1 +# 麦麦活跃度,越高,麦麦回复越多 -talk_frequency = 1 # 麦麦活跃度,越高,麦麦回复越频繁 +focus_value = 1 +# 麦麦的专注思考能力,越高越容易持续连续对话 max_context_size = 25 # 上下文长度 thinking_timeout = 40 # 麦麦一次回复最长思考规划时间,超过这个时间的思考会放弃(往往是api反应太慢)