diff --git a/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte b/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte index b898fe59b7..2562d76a8b 100644 --- a/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte +++ b/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte @@ -82,6 +82,16 @@ } 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) { prompt = prompt.replace('{{INPUT_CONTENT}}', floatingInputValue); floatingInputValue = ''; @@ -106,6 +116,15 @@ role: message.role, content: message.content })), + ...(toolIds.length > 0 + ? { + tool_ids: toolIds + // params: { + // function_calling: 'native' + // } + } + : {}), + stream: true // Enable streaming });