From 0e64ed340501a9445eb88223e8d32eacff09a045 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Mon, 9 Jun 2025 23:27:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9=E4=BB=A5=E5=85=B3=E9=97=AD=20=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=90=8E=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/utils/utils.py | 3 +++ src/config/config.py | 2 ++ src/config/official_configs.py | 7 +++++++ template/bot_config_template.toml | 5 ++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/chat/utils/utils.py b/src/chat/utils/utils.py index 47b629c63..149454abe 100644 --- a/src/chat/utils/utils.py +++ b/src/chat/utils/utils.py @@ -324,6 +324,9 @@ def random_remove_punctuation(text: str) -> str: def process_llm_response(text: str) -> list[str]: + if not global_config.response_post_process.enable_response_post_process: + return [text] + # 先保护颜文字 if global_config.response_splitter.enable_kaomoji_protection: protected_text, kaomoji_mapping = protect_kaomoji(text) diff --git a/src/config/config.py b/src/config/config.py index 6360b973a..893967158 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -25,6 +25,7 @@ from src.config.official_configs import ( MoodConfig, KeywordReactionConfig, ChineseTypoConfig, + ResponsePostProcessConfig, ResponseSplitterConfig, TelemetryConfig, ExperimentalConfig, @@ -157,6 +158,7 @@ class Config(ConfigBase): mood: MoodConfig keyword_reaction: KeywordReactionConfig chinese_typo: ChineseTypoConfig + response_post_process: ResponsePostProcessConfig response_splitter: ResponseSplitterConfig telemetry: TelemetryConfig experimental: ExperimentalConfig diff --git a/src/config/official_configs.py b/src/config/official_configs.py index 1019c77dc..3adff5fac 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -329,6 +329,13 @@ class KeywordReactionConfig(ConfigBase): if not isinstance(rule, KeywordRuleConfig): raise ValueError(f"规则必须是KeywordRuleConfig类型,而不是{type(rule).__name__}") +@dataclass +class ResponsePostProcessConfig(ConfigBase): + """回复后处理配置类""" + + enable_response_post_process: bool = True + """是否启用回复后处理,包括错别字生成器,回复分割器""" + @dataclass class ChineseTypoConfig(ConfigBase): diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index ab585450e..1292602cc 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "2.17.0" +version = "2.18.0" #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- #如果你想要修改配置文件,请在修改后将version的值进行变更 @@ -167,6 +167,9 @@ regex_rules = [ { regex = ["^(?P\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" } ] +[response_post_process] +enable_response_post_process = true # 是否启用回复后处理,包括错别字生成器,回复分割器 + [chinese_typo] enable = true # 是否启用中文错别字生成器 error_rate=0.01 # 单字替换概率