From 61a26722155ec6ee1b629cf8dfcf975098c18331 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 29 Jun 2026 02:20:54 -0500 Subject: [PATCH] refac --- backend/open_webui/utils/middleware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 208807717d..8f3b1d9afc 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2235,7 +2235,7 @@ def sanitize_tool_pairs(messages: list[dict]) -> list[dict]: return sanitized -SKILL_MENTION_RE = re.compile(r'<\$([^|>]+)\|?[^>]*>') +SKILL_MENTION_RE = re.compile(r'<\$([^|>]+)(?:\|[^>]*)?>') def _get_text_parts(message: dict) -> list[str]: @@ -2259,7 +2259,7 @@ def extract_skill_ids_from_messages(messages: list[dict]) -> set[str]: def strip_skill_mentions(messages: list[dict]) -> None: """Replace <$skillId|label> mention tags with the label in message content in-place.""" - strip_re = re.compile(r'<\$[^|>]+\|?([^>]*)>') + strip_re = re.compile(r'<\$[^|>]+(?:\|([^>]*))?>') for message in messages: content = message.get('content') if isinstance(content, str) and strip_re.search(content):