优化标签去除,解决搜索的grok标签问题

This commit is contained in:
liuwei
2026-02-05 10:58:25 +08:00
parent 3723434bd6
commit 99d3128802
2 changed files with 11 additions and 1 deletions

View File

@@ -13,3 +13,12 @@ def remove_trailing_content(text, delimiter='---'):
if index != -1:
return text[:index].strip()
return text
import re
def remove_grok_render_tags(text: str) -> str:
if not text:
return text
cleaned = re.sub(r'<\s*grok:[^>]+?>[\s\S]*?<\s*/\s*grok:[^>]+?>', '', text, flags=re.IGNORECASE)
cleaned = re.sub(r'<\s*grok:[^>]+?/?>', '', cleaned, flags=re.IGNORECASE)
return cleaned