diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 67a49993a3..b3a5258395 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2074,7 +2074,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]: @@ -2088,27 +2088,31 @@ def _get_text_parts(message: dict) -> list[str]: def extract_skill_ids_from_messages(messages: list[dict]) -> set[str]: - """Extract skill IDs from <$skillId|label> mention tags in messages.""" + """Extract skill IDs from <$skillId|label> and mention tags.""" ids: set[str] = set() for message in messages: for text in _get_text_parts(message): - ids.update(m.group(1) for m in SKILL_MENTION_RE.finditer(text)) + ids.update(m.group(1) or m.group(2) for m in SKILL_MENTION_RE.finditer(text)) return ids 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'<\$[^|>]+(?:\|([^>]*))?>') + """Replace <$skillId|label> and mention tags with the label in-place.""" + strip_re = re.compile(r'<(?:\$[^|>]+(?:\|([^>]*))?|/[^|>]+\|([^>]*))>') + + def label(match): + return match.group(1) or match.group(2) or '' + for message in messages: content = message.get('content') if isinstance(content, str) and strip_re.search(content): - message['content'] = strip_re.sub(r'\1', content).strip() + message['content'] = strip_re.sub(label, content).strip() elif isinstance(content, list): for part in content: if isinstance(part, dict) and part.get('type') == 'text': text = part.get('text', '') if strip_re.search(text): - part['text'] = strip_re.sub(r'\1', text).strip() + part['text'] = strip_re.sub(label, text).strip() async def connect_mcp_server( diff --git a/src/lib/components/admin/Settings/Models.svelte b/src/lib/components/admin/Settings/Models.svelte index ebf21eacf0..e70a1baa03 100644 --- a/src/lib/components/admin/Settings/Models.svelte +++ b/src/lib/components/admin/Settings/Models.svelte @@ -691,8 +691,7 @@
@@ -704,13 +703,13 @@ ? `${model?.ollama?.digest} **(${model?.ollama?.modified_at})**` : model.id )} - className=" w-fit" + className="min-w-0 flex-1" placement="top-start" >
- {model.name} + {model.name} +
{#if shiftKey}