diff --git a/scripts/configexe.toml b/scripts/configexe.toml index f8b9a77f1..603393f75 100644 --- a/scripts/configexe.toml +++ b/scripts/configexe.toml @@ -62,6 +62,12 @@ description = "思考的时间间隔(秒),可以有效减少消耗" path = "focus_chat.think_interval" type = "number" +[[editor.quick_settings.items]] +name = "连续回复能力(focus模式)" +description = "连续回复能力,值越高,麦麦连续回复的概率越高" +path = "focus_chat.consecutive_replies" +type = "number" + [[editor.quick_settings.items]] name = "自我识别处理器(focus模式)" description = "是否启用自我识别处理器" @@ -86,6 +92,8 @@ description = "是否在回复后显示当前聊天模式" path = "experimental.debug_show_chat_mode" type = "bool" + + [translations.sections.inner] name = "版本" description = "麦麦的内部配置,包含版本号等信息。此部分仅供显示,不可编辑。" @@ -290,6 +298,10 @@ description = "需要降低回复频率的群组列表" name = "思考间隔" description = "思考的时间间隔(秒),可以有效减少消耗" +[translations.items.consecutive_replies] +name = "连续回复能力" +description = "连续回复能力,值越高,麦麦连续回复的概率越高" + [translations.items.observation_context_size] name = "观察上下文大小" description = "观察到的最长上下文大小,建议15,太短太长都会导致脑袋尖尖" diff --git a/src/chat/focus_chat/planners/modify_actions.py b/src/chat/focus_chat/planners/modify_actions.py index c376426a6..dd888a96d 100644 --- a/src/chat/focus_chat/planners/modify_actions.py +++ b/src/chat/focus_chat/planners/modify_actions.py @@ -143,20 +143,32 @@ class ActionModifier: result["remove"].append("no_reply") result["remove"].append("reply") - # 获取最近三次的reply状态 - last_three = reply_sequence[-3:] if len(reply_sequence) >= 3 else reply_sequence + # 获取最近max_reply_num次的reply状态 + max_reply_num = int(global_config.focus_chat.consecutive_replies * 3) + sec_thres_reply_num = int(global_config.focus_chat.consecutive_replies * 2) + one_thres_reply_num = int(global_config.focus_chat.consecutive_replies * 1) + last_max_reply_num = reply_sequence[-max_reply_num:] if len(reply_sequence) >= max_reply_num else reply_sequence # 根据最近的reply情况决定是否移除reply动作 - if len(last_three) >= 3 and all(last_three): - # 如果最近三次都是reply,直接移除 + if len(last_max_reply_num) >= max_reply_num and all(last_max_reply_num): + # 如果最近max_reply_num次都是reply,直接移除 result["remove"].append("reply") - elif len(last_three) >= 2 and all(last_three[-2:]): - # 如果最近两次都是reply,40%概率移除 - if random.random() < 0.4: + logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply,{len(last_max_reply_num) - no_reply_count}次reply,直接移除") + elif len(last_max_reply_num) >= sec_thres_reply_num and all(last_max_reply_num[-sec_thres_reply_num:]): + # 如果最近sec_thres_reply_num次都是reply,40%概率移除 + if random.random() < 0.4 / global_config.focus_chat.consecutive_replies: result["remove"].append("reply") - elif last_three and last_three[-1]: - # 如果最近一次是reply,20%概率移除 - if random.random() < 0.2: + logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply,{len(last_max_reply_num) - no_reply_count}次reply,{0.4 / global_config.focus_chat.consecutive_replies}概率移除,移除") + else: + logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply,{len(last_max_reply_num) - no_reply_count}次reply,{0.4 / global_config.focus_chat.consecutive_replies}概率移除,不移除") + elif len(last_max_reply_num) >= one_thres_reply_num and all(last_max_reply_num[-one_thres_reply_num:]): + # 如果最近one_thres_reply_num次都是reply,20%概率移除 + if random.random() < 0.2 / global_config.focus_chat.consecutive_replies: result["remove"].append("reply") + logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply,{len(last_max_reply_num) - no_reply_count}次reply,{0.2 / global_config.focus_chat.consecutive_replies}概率移除,移除") + else: + logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply,{len(last_max_reply_num) - no_reply_count}次reply,{0.2 / global_config.focus_chat.consecutive_replies}概率移除,不移除") + else: + logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply,{len(last_max_reply_num) - no_reply_count}次reply,无需移除") return result diff --git a/src/common/logger.py b/src/common/logger.py index 51d6e6ed1..5a255c90d 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -885,6 +885,17 @@ API_SERVER_STYLE_CONFIG = { }, } +ACTION_MANAGER_STYLE_CONFIG = { + "advanced": { + "console_format": "{time:HH:mm:ss} | 动作选择 | {message}", + "file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 动作选择 | {message}", + }, + "simple": { + "console_format": "{time:HH:mm:ss} | 动作选择 | {message}", + "file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 动作选择 | {message}", + }, +} + # maim_message 消息服务样式配置 MAIM_MESSAGE_STYLE_CONFIG = { "advanced": { @@ -909,6 +920,9 @@ EMOJI_STYLE_CONFIG = EMOJI_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else EMOJI_ST PFC_ACTION_PLANNER_STYLE_CONFIG = ( PFC_ACTION_PLANNER_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else PFC_ACTION_PLANNER_STYLE_CONFIG["advanced"] ) +ACTION_MANAGER_STYLE_CONFIG = ( + ACTION_MANAGER_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else ACTION_MANAGER_STYLE_CONFIG["advanced"] +) REMOTE_STYLE_CONFIG = REMOTE_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else REMOTE_STYLE_CONFIG["advanced"] BASE_TOOL_STYLE_CONFIG = BASE_TOOL_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else BASE_TOOL_STYLE_CONFIG["advanced"] PERSON_INFO_STYLE_CONFIG = PERSON_INFO_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else PERSON_INFO_STYLE_CONFIG["advanced"] diff --git a/src/common/logger_manager.py b/src/common/logger_manager.py index 317c41e35..be75b0018 100644 --- a/src/common/logger_manager.py +++ b/src/common/logger_manager.py @@ -48,6 +48,7 @@ from src.common.logger import ( API_SERVER_STYLE_CONFIG, NORMAL_CHAT_RESPONSE_STYLE_CONFIG, EXPRESS_STYLE_CONFIG, + ACTION_MANAGER_STYLE_CONFIG, ) # 可根据实际需要补充更多模块配置 @@ -100,6 +101,7 @@ MODULE_LOGGER_CONFIGS = { "normal_chat": NORMAL_CHAT_STYLE_CONFIG, # 一般水群 "focus_chat": FOCUS_CHAT_STYLE_CONFIG, # 专注水群 "expressor": EXPRESS_STYLE_CONFIG, # 麦麦表达 + "action_manager": ACTION_MANAGER_STYLE_CONFIG, # 动作选择 # ...如有更多模块,继续添加... } diff --git a/src/config/official_configs.py b/src/config/official_configs.py index 8f98256e9..ec388c43b 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -143,6 +143,9 @@ class FocusChatConfig(ConfigBase): think_interval: int = 1 """思考间隔(秒)""" + + consecutive_replies: int = 1 + """连续回复能力,值越高,麦麦连续回复的概率越高""" @dataclass diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 5f7b1c286..95d329cdc 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "2.6.0" +version = "2.7.0" #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- #如果你想要修改配置文件,请在修改后将version的值进行变更 @@ -92,6 +92,8 @@ talk_frequency_down_groups = [] #降低回复频率的群号码 [focus_chat] #专注聊天 think_interval = 3 # 思考间隔 单位秒,可以有效减少消耗 +consecutive_replies = 1 # 连续回复能力,值越高,麦麦连续回复的概率越高 + observation_context_size = 16 # 观察到的最长上下文大小,建议15,太短太长都会导致脑袋尖尖 compressed_length = 8 # 不能大于observation_context_size,心流上下文压缩的最短压缩长度,超过心流观察到的上下文长度,会压缩,最短压缩长度为5