diff --git a/src/chat/utils/utils.py b/src/chat/utils/utils.py index cb1559dc..53b1601e 100644 --- a/src/chat/utils/utils.py +++ b/src/chat/utils/utils.py @@ -405,8 +405,12 @@ def process_llm_response(text: str, enable_splitter: bool = True, enable_chinese sentences.append(sentence) if len(sentences) > max_sentence_num: - logger.warning(f"分割后消息数量过多 ({len(sentences)} 条),返回默认回复") - return [_get_random_default_reply()] + if global_config.response_splitter.enable_overflow_return_all: + logger.warning(f"分割后消息数量过多 ({len(sentences)} 条),合并后一次返回") + sentences = ["".join(sentences)] + else: + logger.warning(f"分割后消息数量过多 ({len(sentences)} 条),返回默认回复") + return [_get_random_default_reply()] # if extracted_contents: # for content in extracted_contents: diff --git a/src/config/official_configs.py b/src/config/official_configs.py index ad933148..e21d8f96 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -626,6 +626,9 @@ class ResponseSplitterConfig(ConfigBase): enable_kaomoji_protection: bool = False """是否启用颜文字保护""" + enable_overflow_return_all: bool = False + """是否在超出句子数量限制时合并后一次性返回""" + @dataclass class TelemetryConfig(ConfigBase): diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 389859d4..52ace70d 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "6.20.2" +version = "6.20.3" #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- #如果你想要修改配置文件,请递增version的值 @@ -206,6 +206,7 @@ enable = true # 是否启用回复分割器 max_length = 512 # 回复允许的最大长度 max_sentence_num = 8 # 回复允许的最大句子数 enable_kaomoji_protection = false # 是否启用颜文字保护 +enable_overflow_return_all = false # 是否在句子数量超出回复允许的最大句子数时一次性返回全部内容 [log] date_style = "m-d H:i:s" # 日期格式 @@ -253,4 +254,4 @@ chat_prompts = [] #此系统暂时移除,无效配置 [relationship] -enable_relationship = true # 是否启用关系系统 \ No newline at end of file +enable_relationship = true # 是否启用关系系统