fix: strip markdown links, URLs, bold/italic from antaf response
Antaf returns markdown with hyperlinks and formatting that TTS reads out as raw text. Now cleaned before sending to TTS. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6707351540
commit
49ae06ae45
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue