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 # 单字替换概率