mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-15 05:45:19 +00:00
refac
This commit is contained in:
parent
056431606b
commit
f8e8d7e048
1 changed files with 10 additions and 0 deletions
|
|
@ -84,11 +84,21 @@
|
||||||
let prompt = selectedAction?.prompt ?? '';
|
let prompt = selectedAction?.prompt ?? '';
|
||||||
let toolIds = [];
|
let toolIds = [];
|
||||||
|
|
||||||
|
// Handle: {{variableId|tool:id="toolId"}} pattern
|
||||||
|
// This regex captures variableId and toolId from {{variableId|tool:id="toolId"}}
|
||||||
|
const varToolPattern = /\{\{(.*?)\|tool:id="([^"]+)"\}\}/g;
|
||||||
|
prompt = prompt.replace(varToolPattern, (match, variableId, toolId) => {
|
||||||
|
toolIds.push(toolId);
|
||||||
|
return variableId; // Replace with just variableId
|
||||||
|
});
|
||||||
|
|
||||||
|
// legacy {{TOOL:toolId}} pattern (for backward compatibility)
|
||||||
let toolIdPattern = /\{\{TOOL:([^\}]+)\}\}/g;
|
let toolIdPattern = /\{\{TOOL:([^\}]+)\}\}/g;
|
||||||
let match;
|
let match;
|
||||||
while ((match = toolIdPattern.exec(prompt)) !== null) {
|
while ((match = toolIdPattern.exec(prompt)) !== null) {
|
||||||
toolIds.push(match[1]);
|
toolIds.push(match[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all TOOL placeholders from the prompt
|
// Remove all TOOL placeholders from the prompt
|
||||||
prompt = prompt.replace(toolIdPattern, '');
|
prompt = prompt.replace(toolIdPattern, '');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue