fix:是否保护颜文字进入config
This commit is contained in:
@@ -221,7 +221,6 @@ class BotConfig:
|
|||||||
max_emoji_num: int = 200 # 表情包最大数量
|
max_emoji_num: int = 200 # 表情包最大数量
|
||||||
max_reach_deletion: bool = True # 开启则在达到最大数量时删除表情包,关闭则不会继续收集表情包
|
max_reach_deletion: bool = True # 开启则在达到最大数量时删除表情包,关闭则不会继续收集表情包
|
||||||
EMOJI_CHECK_INTERVAL: int = 120 # 表情包检查间隔(分钟)
|
EMOJI_CHECK_INTERVAL: int = 120 # 表情包检查间隔(分钟)
|
||||||
EMOJI_REGISTER_INTERVAL: int = 10 # 表情包注册间隔(分钟)
|
|
||||||
|
|
||||||
save_pic: bool = False # 是否保存图片
|
save_pic: bool = False # 是否保存图片
|
||||||
save_emoji: bool = False # 是否保存表情包
|
save_emoji: bool = False # 是否保存表情包
|
||||||
@@ -263,6 +262,7 @@ class BotConfig:
|
|||||||
chinese_typo_word_replace_rate = 0.02 # 整词替换概率
|
chinese_typo_word_replace_rate = 0.02 # 整词替换概率
|
||||||
|
|
||||||
# response_splitter
|
# response_splitter
|
||||||
|
enable_kaomoji_protection = False # 是否启用颜文字保护
|
||||||
enable_response_splitter = True # 是否启用回复分割器
|
enable_response_splitter = True # 是否启用回复分割器
|
||||||
response_max_length = 100 # 回复允许的最大长度
|
response_max_length = 100 # 回复允许的最大长度
|
||||||
response_max_sentence_num = 3 # 回复允许的最大句子数
|
response_max_sentence_num = 3 # 回复允许的最大句子数
|
||||||
@@ -394,7 +394,6 @@ class BotConfig:
|
|||||||
def emoji(parent: dict):
|
def emoji(parent: dict):
|
||||||
emoji_config = parent["emoji"]
|
emoji_config = parent["emoji"]
|
||||||
config.EMOJI_CHECK_INTERVAL = emoji_config.get("check_interval", config.EMOJI_CHECK_INTERVAL)
|
config.EMOJI_CHECK_INTERVAL = emoji_config.get("check_interval", config.EMOJI_CHECK_INTERVAL)
|
||||||
config.EMOJI_REGISTER_INTERVAL = emoji_config.get("register_interval", config.EMOJI_REGISTER_INTERVAL)
|
|
||||||
config.EMOJI_CHECK_PROMPT = emoji_config.get("check_prompt", config.EMOJI_CHECK_PROMPT)
|
config.EMOJI_CHECK_PROMPT = emoji_config.get("check_prompt", config.EMOJI_CHECK_PROMPT)
|
||||||
config.EMOJI_CHECK = emoji_config.get("enable_check", config.EMOJI_CHECK)
|
config.EMOJI_CHECK = emoji_config.get("enable_check", config.EMOJI_CHECK)
|
||||||
if config.INNER_VERSION in SpecifierSet(">=1.1.1"):
|
if config.INNER_VERSION in SpecifierSet(">=1.1.1"):
|
||||||
@@ -428,21 +427,9 @@ class BotConfig:
|
|||||||
|
|
||||||
def heartflow(parent: dict):
|
def heartflow(parent: dict):
|
||||||
heartflow_config = parent["heartflow"]
|
heartflow_config = parent["heartflow"]
|
||||||
# 加载新增的 heartflowC 参数
|
|
||||||
|
|
||||||
# 加载原有的 heartflow 参数
|
|
||||||
# config.sub_heart_flow_update_interval = heartflow_config.get(
|
|
||||||
# "sub_heart_flow_update_interval", config.sub_heart_flow_update_interval
|
|
||||||
# )
|
|
||||||
# config.sub_heart_flow_freeze_time = heartflow_config.get(
|
|
||||||
# "sub_heart_flow_freeze_time", config.sub_heart_flow_freeze_time
|
|
||||||
# )
|
|
||||||
config.sub_heart_flow_stop_time = heartflow_config.get(
|
config.sub_heart_flow_stop_time = heartflow_config.get(
|
||||||
"sub_heart_flow_stop_time", config.sub_heart_flow_stop_time
|
"sub_heart_flow_stop_time", config.sub_heart_flow_stop_time
|
||||||
)
|
)
|
||||||
# config.heart_flow_update_interval = heartflow_config.get(
|
|
||||||
# "heart_flow_update_interval", config.heart_flow_update_interval
|
|
||||||
# )
|
|
||||||
if config.INNER_VERSION in SpecifierSet(">=1.3.0"):
|
if config.INNER_VERSION in SpecifierSet(">=1.3.0"):
|
||||||
config.observation_context_size = heartflow_config.get(
|
config.observation_context_size = heartflow_config.get(
|
||||||
"observation_context_size", config.observation_context_size
|
"observation_context_size", config.observation_context_size
|
||||||
@@ -654,6 +641,10 @@ class BotConfig:
|
|||||||
config.response_max_sentence_num = response_splitter_config.get(
|
config.response_max_sentence_num = response_splitter_config.get(
|
||||||
"response_max_sentence_num", config.response_max_sentence_num
|
"response_max_sentence_num", config.response_max_sentence_num
|
||||||
)
|
)
|
||||||
|
if config.INNER_VERSION in SpecifierSet(">=1.4.2"):
|
||||||
|
config.enable_kaomoji_protection = response_splitter_config.get(
|
||||||
|
"enable_kaomoji_protection", config.enable_kaomoji_protection
|
||||||
|
)
|
||||||
|
|
||||||
def groups(parent: dict):
|
def groups(parent: dict):
|
||||||
groups_config = parent["groups"]
|
groups_config = parent["groups"]
|
||||||
|
|||||||
@@ -372,8 +372,12 @@ def random_remove_punctuation(text: str) -> str:
|
|||||||
|
|
||||||
def process_llm_response(text: str) -> List[str]:
|
def process_llm_response(text: str) -> List[str]:
|
||||||
# 先保护颜文字
|
# 先保护颜文字
|
||||||
protected_text, kaomoji_mapping = protect_kaomoji(text)
|
if global_config.enable_kaomoji_protection:
|
||||||
logger.trace(f"保护颜文字后的文本: {protected_text}")
|
protected_text, kaomoji_mapping = protect_kaomoji(text)
|
||||||
|
logger.trace(f"保护颜文字后的文本: {protected_text}")
|
||||||
|
else:
|
||||||
|
protected_text = text
|
||||||
|
kaomoji_mapping = {}
|
||||||
# 提取被 () 或 [] 包裹且包含中文的内容
|
# 提取被 () 或 [] 包裹且包含中文的内容
|
||||||
pattern = re.compile(r"[\(\[\(](?=.*[\u4e00-\u9fff]).*?[\)\]\)]")
|
pattern = re.compile(r"[\(\[\(](?=.*[\u4e00-\u9fff]).*?[\)\]\)]")
|
||||||
# _extracted_contents = pattern.findall(text)
|
# _extracted_contents = pattern.findall(text)
|
||||||
@@ -426,9 +430,8 @@ def process_llm_response(text: str) -> List[str]:
|
|||||||
# sentences.append(content)
|
# sentences.append(content)
|
||||||
|
|
||||||
# 在所有句子处理完毕后,对包含占位符的列表进行恢复
|
# 在所有句子处理完毕后,对包含占位符的列表进行恢复
|
||||||
sentences = recover_kaomoji(sentences, kaomoji_mapping)
|
if global_config.enable_kaomoji_protection:
|
||||||
|
sentences = recover_kaomoji(sentences, kaomoji_mapping)
|
||||||
# print(sentences)
|
|
||||||
|
|
||||||
return sentences
|
return sentences
|
||||||
|
|
||||||
|
|||||||
@@ -122,16 +122,12 @@ mentioned_bot_inevitable_reply = false # 提及 bot 必然回复
|
|||||||
at_bot_inevitable_reply = false # @bot 必然回复
|
at_bot_inevitable_reply = false # @bot 必然回复
|
||||||
|
|
||||||
[emoji]
|
[emoji]
|
||||||
max_emoji_num = 90 # 表情包最大数量
|
max_emoji_num = 40 # 表情包最大数量
|
||||||
max_reach_deletion = true # 开启则在达到最大数量时删除表情包,关闭则达到最大数量时不删除,只是不会继续收集表情包
|
max_reach_deletion = true # 开启则在达到最大数量时删除表情包,关闭则达到最大数量时不删除,只是不会继续收集表情包
|
||||||
check_interval = 30 # 检查表情包(注册,破损,删除)的时间间隔(分钟)
|
check_interval = 10 # 检查表情包(注册,破损,删除)的时间间隔(分钟)
|
||||||
|
|
||||||
auto_save = true # 是否保存表情包和图片
|
|
||||||
|
|
||||||
save_pic = false # 是否保存图片
|
save_pic = false # 是否保存图片
|
||||||
save_emoji = false # 是否保存表情包
|
save_emoji = false # 是否保存表情包
|
||||||
steal_emoji = true # 是否偷取表情包,让麦麦可以发送她保存的这些表情包
|
steal_emoji = true # 是否偷取表情包,让麦麦可以发送她保存的这些表情包
|
||||||
|
|
||||||
enable_check = false # 是否启用表情包过滤,只有符合该要求的表情包才会被保存
|
enable_check = false # 是否启用表情包过滤,只有符合该要求的表情包才会被保存
|
||||||
check_prompt = "符合公序良俗" # 表情包过滤要求,只有符合该要求的表情包才会被保存
|
check_prompt = "符合公序良俗" # 表情包过滤要求,只有符合该要求的表情包才会被保存
|
||||||
|
|
||||||
@@ -185,6 +181,7 @@ word_replace_rate=0.006 # 整词替换概率
|
|||||||
enable_response_splitter = true # 是否启用回复分割器
|
enable_response_splitter = true # 是否启用回复分割器
|
||||||
response_max_length = 256 # 回复允许的最大长度
|
response_max_length = 256 # 回复允许的最大长度
|
||||||
response_max_sentence_num = 4 # 回复允许的最大句子数
|
response_max_sentence_num = 4 # 回复允许的最大句子数
|
||||||
|
enable_kaomoji_protection = false # 是否启用颜文字保护
|
||||||
|
|
||||||
[remote] #发送统计信息,主要是看全球有多少只麦麦
|
[remote] #发送统计信息,主要是看全球有多少只麦麦
|
||||||
enable = true
|
enable = true
|
||||||
|
|||||||
Reference in New Issue
Block a user