优化标签去除,解决搜索的grok标签问题
This commit is contained in:
@@ -18,7 +18,7 @@ from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
||||
from utils.decorator.points_decorator import plugin_points_cost
|
||||
from utils.media_downloader import MediaDownloader
|
||||
from utils.string_utils import remove_trailing_content
|
||||
from utils.string_utils import remove_trailing_content, remove_grok_render_tags
|
||||
from wechat_ipad import WechatAPIClient
|
||||
import aiohttp
|
||||
|
||||
@@ -181,6 +181,7 @@ class DifyPlugin(MessagePluginInterface):
|
||||
|
||||
# 去除广告内容
|
||||
response = remove_trailing_content(response)
|
||||
response = remove_grok_render_tags(response)
|
||||
self.LOG.debug(f"处理后的响应: {response}")
|
||||
|
||||
# 发送回复
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user