feat:添加配置项以关闭 消息后处理
This commit is contained in:
@@ -324,6 +324,9 @@ def random_remove_punctuation(text: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def process_llm_response(text: str) -> list[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:
|
if global_config.response_splitter.enable_kaomoji_protection:
|
||||||
protected_text, kaomoji_mapping = protect_kaomoji(text)
|
protected_text, kaomoji_mapping = protect_kaomoji(text)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from src.config.official_configs import (
|
|||||||
MoodConfig,
|
MoodConfig,
|
||||||
KeywordReactionConfig,
|
KeywordReactionConfig,
|
||||||
ChineseTypoConfig,
|
ChineseTypoConfig,
|
||||||
|
ResponsePostProcessConfig,
|
||||||
ResponseSplitterConfig,
|
ResponseSplitterConfig,
|
||||||
TelemetryConfig,
|
TelemetryConfig,
|
||||||
ExperimentalConfig,
|
ExperimentalConfig,
|
||||||
@@ -157,6 +158,7 @@ class Config(ConfigBase):
|
|||||||
mood: MoodConfig
|
mood: MoodConfig
|
||||||
keyword_reaction: KeywordReactionConfig
|
keyword_reaction: KeywordReactionConfig
|
||||||
chinese_typo: ChineseTypoConfig
|
chinese_typo: ChineseTypoConfig
|
||||||
|
response_post_process: ResponsePostProcessConfig
|
||||||
response_splitter: ResponseSplitterConfig
|
response_splitter: ResponseSplitterConfig
|
||||||
telemetry: TelemetryConfig
|
telemetry: TelemetryConfig
|
||||||
experimental: ExperimentalConfig
|
experimental: ExperimentalConfig
|
||||||
|
|||||||
@@ -329,6 +329,13 @@ class KeywordReactionConfig(ConfigBase):
|
|||||||
if not isinstance(rule, KeywordRuleConfig):
|
if not isinstance(rule, KeywordRuleConfig):
|
||||||
raise ValueError(f"规则必须是KeywordRuleConfig类型,而不是{type(rule).__name__}")
|
raise ValueError(f"规则必须是KeywordRuleConfig类型,而不是{type(rule).__name__}")
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ResponsePostProcessConfig(ConfigBase):
|
||||||
|
"""回复后处理配置类"""
|
||||||
|
|
||||||
|
enable_response_post_process: bool = True
|
||||||
|
"""是否启用回复后处理,包括错别字生成器,回复分割器"""
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ChineseTypoConfig(ConfigBase):
|
class ChineseTypoConfig(ConfigBase):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[inner]
|
[inner]
|
||||||
version = "2.17.0"
|
version = "2.18.0"
|
||||||
|
|
||||||
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
||||||
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
||||||
@@ -167,6 +167,9 @@ regex_rules = [
|
|||||||
{ regex = ["^(?P<n>\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" }
|
{ regex = ["^(?P<n>\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[response_post_process]
|
||||||
|
enable_response_post_process = true # 是否启用回复后处理,包括错别字生成器,回复分割器
|
||||||
|
|
||||||
[chinese_typo]
|
[chinese_typo]
|
||||||
enable = true # 是否启用中文错别字生成器
|
enable = true # 是否启用中文错别字生成器
|
||||||
error_rate=0.01 # 单字替换概率
|
error_rate=0.01 # 单字替换概率
|
||||||
|
|||||||
Reference in New Issue
Block a user