diff --git a/modules/antaf/antaf_llm.py b/modules/antaf/antaf_llm.py index a147b13..78aecf3 100644 --- a/modules/antaf/antaf_llm.py +++ b/modules/antaf/antaf_llm.py @@ -40,13 +40,24 @@ class LLMProvider(LLMProviderBase): @staticmethod def _clean_text(text): - """清理阿福返回文本中的脏数据""" + """清理阿福返回文本中的脏数据、链接、markdown""" + import re # 去掉阿福内部状态文本 junk = [ "完成资料引用", "内容生成", "正在思考", "正在搜索", ] for j in junk: text = text.replace(j, "") + # Markdown链接 [文字](url) → 只保留文字 + text = re.sub(r'\[([^\]]+)\]\([^)]+\)', r'\1', text) + # 裸URL + text = re.sub(r'https?://\S+', '', text) + # Markdown加粗 **文字** → 文字 + text = re.sub(r'\*\*([^*]+)\*\*', r'\1', text) + # Markdown斜体 *文字* → 文字 + text = re.sub(r'\*([^*]+)\*', r'\1', text) + # 多余空格 + text = re.sub(r' +', ' ', text) return text.strip() @staticmethod