From 99d31288025dd46c817dfeecbd1f4f7affb37421 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 5 Feb 2026 10:58:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=87=E7=AD=BE=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=90=9C=E7=B4=A2=E7=9A=84?= =?UTF-8?q?grok=E6=A0=87=E7=AD=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/dify/main.py | 3 ++- utils/string_utils.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/dify/main.py b/plugins/dify/main.py index b3d7502..d651e98 100644 --- a/plugins/dify/main.py +++ b/plugins/dify/main.py @@ -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}") # 发送回复 diff --git a/utils/string_utils.py b/utils/string_utils.py index 92b11ef..d39033e 100644 --- a/utils/string_utils.py +++ b/utils/string_utils.py @@ -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