mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 08:25:01 -06:00
refac
This commit is contained in:
@@ -2516,44 +2516,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Parse skill mentions (<$skillId|label>) from user messages
|
||||
const skillMentionRegex = /<\$([^|>]+)\|?[^>]*>/g;
|
||||
// Menu-selected skills are sent as IDs; inline <$skillId|label> mentions stay
|
||||
// in the message so the backend can inject their full content.
|
||||
const skillIds = [...selectedSkillIds];
|
||||
const mentionSkillIds = [];
|
||||
for (const message of messages) {
|
||||
const content =
|
||||
typeof message.content === 'string' ? message.content : (message.content?.[0]?.text ?? '');
|
||||
for (const match of content.matchAll(skillMentionRegex)) {
|
||||
if (!mentionSkillIds.includes(match[1])) {
|
||||
mentionSkillIds.push(match[1]);
|
||||
}
|
||||
if (!skillIds.includes(match[1])) {
|
||||
skillIds.push(match[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Strip skill mentions from message content
|
||||
if (mentionSkillIds.length > 0) {
|
||||
messages = messages.map((message) => {
|
||||
if (typeof message.content === 'string') {
|
||||
return {
|
||||
...message,
|
||||
content: message.content.replace(/<\$[^>]+>/g, '').trim()
|
||||
};
|
||||
} else if (Array.isArray(message.content)) {
|
||||
return {
|
||||
...message,
|
||||
content: message.content.map((part) =>
|
||||
part.type === 'text'
|
||||
? { ...part, text: part.text.replace(/<\$[^>]+>/g, '').trim() }
|
||||
: part
|
||||
)
|
||||
};
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
|
||||
// Use the user-selected terminal from the dropdown
|
||||
const activeTerminalId = $selectedTerminalId ?? null;
|
||||
|
||||
Reference in New Issue
Block a user