enh: tool calling support in quick actions

This commit is contained in:
Timothy Jaeryang Baek
2025-08-08 13:43:30 +04:00
parent ff9f2614f3
commit 056431606b

View File

@@ -82,6 +82,16 @@
} }
let prompt = selectedAction?.prompt ?? ''; let prompt = selectedAction?.prompt ?? '';
let toolIds = [];
let toolIdPattern = /\{\{TOOL:([^\}]+)\}\}/g;
let match;
while ((match = toolIdPattern.exec(prompt)) !== null) {
toolIds.push(match[1]);
}
// Remove all TOOL placeholders from the prompt
prompt = prompt.replace(toolIdPattern, '');
if (prompt.includes('{{INPUT_CONTENT}}') && !floatingInput) { if (prompt.includes('{{INPUT_CONTENT}}') && !floatingInput) {
prompt = prompt.replace('{{INPUT_CONTENT}}', floatingInputValue); prompt = prompt.replace('{{INPUT_CONTENT}}', floatingInputValue);
floatingInputValue = ''; floatingInputValue = '';
@@ -106,6 +116,15 @@
role: message.role, role: message.role,
content: message.content content: message.content
})), })),
...(toolIds.length > 0
? {
tool_ids: toolIds
// params: {
// function_calling: 'native'
// }
}
: {}),
stream: true // Enable streaming stream: true // Enable streaming
}); });