From a6c4bcd6cf9af9e53f68cdd0024c6c6a886fb046 Mon Sep 17 00:00:00 2001 From: Bakadax Date: Thu, 15 May 2025 16:56:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=EF=BC=88=EF=BC=89()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/utils/utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/chat/utils/utils.py b/src/chat/utils/utils.py index 1974d1c8..20338271 100644 --- a/src/chat/utils/utils.py +++ b/src/chat/utils/utils.py @@ -406,17 +406,17 @@ def process_llm_response(text: str) -> list[str]: else: protected_text = text kaomoji_mapping = {} - # # 提取被 () 或 [] 包裹且包含中文的内容 - # pattern = re.compile(r"[(\[(](?=.*[一-鿿]).*?[)\])]") - # # _extracted_contents = pattern.findall(text) - # _extracted_contents = pattern.findall(protected_text) # 在保护后的文本上查找 - # # 去除 () 和 [] 及其包裹的内容 - # cleaned_text = pattern.sub("", protected_text) + # 提取被 [] 包裹且包含中文的内容 + pattern = re.compile(r"[\[](?=.*[一-鿿]).*?[\])]") + # _extracted_contents = pattern.findall(text) + _extracted_contents = pattern.findall(protected_text) # 在保护后的文本上查找 + # 去除 () 和 [] 及其包裹的内容 + cleaned_text = pattern.sub("", protected_text) - # if cleaned_text == "": - # return ["呃呃"] + if cleaned_text == "": + return ["呃呃"] - # logger.debug(f"{text}去除括号处理后的文本: {cleaned_text}") + logger.debug(f"{text}去除括号处理后的文本: {cleaned_text}") cleaned_text = protected_text # 对清理后的文本进行进一步处理 max_length = global_config.response_max_length * 2