From e4b9b9e5d1dd21a62247b458c7fa5dc618885f51 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Sun, 15 Jun 2025 01:14:07 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=8F=82=E6=95=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4=EF=BC=8C=E6=8F=90=E9=82=A3=E5=AE=B6=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/focus_chat/expressors/default_expressor.py | 4 ++-- src/chat/normal_chat/normal_chat.py | 4 ++-- src/chat/normal_chat/normal_chat_action_modifier.py | 2 +- src/config/official_configs.py | 3 +++ template/bot_config_template.toml | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/chat/focus_chat/expressors/default_expressor.py b/src/chat/focus_chat/expressors/default_expressor.py index 816ff7347..9be412c83 100644 --- a/src/chat/focus_chat/expressors/default_expressor.py +++ b/src/chat/focus_chat/expressors/default_expressor.py @@ -28,7 +28,7 @@ logger = get_logger("expressor") def init_prompt(): Prompt( """ -你可以参考以下的语言习惯,如果情景合适就使用,不要盲目使用,不要生硬使用,而是结合到表达中: +你可以参考你的以下的语言习惯,如果情景合适就使用,不要盲目使用,不要生硬使用,而是结合到表达中: {style_habbits} 你现在正在群里聊天,以下是群里正在进行的聊天内容: @@ -38,7 +38,7 @@ def init_prompt(): {chat_target} 你的名字是{bot_name},{prompt_personality},在这聊天中,"{target_message}"引起了你的注意,对这句话,你想表达:{in_mind_reply},原因是:{reason}。你现在要思考怎么回复 -你需要使用合适的语法和句法,参考聊天内容,组织一条日常且口语化的回复。 +你需要使用合适的语法和句法,参考聊天内容,组织一条日常且口语化的回复。请你修改你想表达的原句,符合你的表达风格和语言习惯 请你根据情景使用以下句法: {grammar_habbits} {config_expression_style},你可以完全重组回复,保留最基本的表达含义就好,但重组后保持语意通顺。 diff --git a/src/chat/normal_chat/normal_chat.py b/src/chat/normal_chat/normal_chat.py index 0cb7f9cc8..7c23492bc 100644 --- a/src/chat/normal_chat/normal_chat.py +++ b/src/chat/normal_chat/normal_chat.py @@ -750,14 +750,14 @@ class NormalChat: reply_ratio = reply_count / total_messages if total_messages > 0 else 0 # 使用对数函数让低比率时概率上升更快:log(1 + ratio * k) / log(1 + k) + base # k=7时,0.05比率对应约0.4概率,0.1比率对应约0.6概率,0.2比率对应约0.8概率 - k_reply = 7 + k_reply = 7 * global_config.normal_chat.relation_frequency base_reply_prob = 0.1 # 基础概率10% reply_build_probability = (math.log(1 + reply_ratio * k_reply) / math.log(1 + k_reply)) * 0.9 + base_reply_prob if reply_ratio > 0 else base_reply_prob # 计算接收概率(receive_count的影响) receive_ratio = receive_count / total_messages if total_messages > 0 else 0 # 接收概率使用更温和的对数曲线,最大0.5,基础0.08 - k_receive = 6 + k_receive = 6 * global_config.normal_chat.relation_frequency base_receive_prob = 0.08 # 基础概率8% receive_build_probability = (math.log(1 + receive_ratio * k_receive) / math.log(1 + k_receive)) * 0.42 + base_receive_prob if receive_ratio > 0 else base_receive_prob diff --git a/src/chat/normal_chat/normal_chat_action_modifier.py b/src/chat/normal_chat/normal_chat_action_modifier.py index f2f9ee1a1..38d02e95a 100644 --- a/src/chat/normal_chat/normal_chat_action_modifier.py +++ b/src/chat/normal_chat/normal_chat_action_modifier.py @@ -309,7 +309,7 @@ class NormalChatActionModifier: if container: thinking_count = sum(1 for msg in container.messages if isinstance(msg, MessageThinking)) print(f"thinking_count: {thinking_count}") - if thinking_count >= 4 / global_config.chat.auto_focus_threshold: # 如果堆积超过3条思考消息 + if thinking_count >= 4 * global_config.chat.auto_focus_threshold: # 如果堆积超过3条思考消息 logger.debug(f"{self.log_prefix} 检测到思考消息堆积({thinking_count}条),切换到focus模式") return True diff --git a/src/config/official_configs.py b/src/config/official_configs.py index a98180d57..6984073f6 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -57,6 +57,9 @@ class RelationshipConfig(ConfigBase): build_relationship_interval: int = 600 """构建关系间隔 单位秒,如果为0则不构建关系""" + + relation_frequency: int = 1 + """关系频率,麦麦构建关系的速度,仅在normal_chat模式下有效""" @dataclass diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index ead9ce7a6..8c93cfa41 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "2.20.0" +version = "2.21.0" #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- #如果你想要修改配置文件,请在修改后将version的值进行变更 @@ -46,6 +46,7 @@ learning_interval = 600 # 学习间隔 单位秒 [relationship] enable_relationship = true # 是否启用关系系统 +relation_frequency = 1 # 关系频率,麦麦构建关系的速度,仅在normal_chat模式下有效 [chat] #麦麦的聊天通用设置 chat_mode = "normal" # 聊天模式 —— 普通模式:normal,专注模式:focus,在普通模式和专注模式之间自动切换