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