From 1b534f8eb6c8454d3ad33296104b910bd3c1e162 Mon Sep 17 00:00:00 2001 From: Andy Brenneke Date: Wed, 24 Jan 2024 15:32:59 -0800 Subject: [PATCH] Do not always override an assistant's tools list in Run Thread node --- .../src/plugins/openai/nodes/RunThreadNode.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/core/src/plugins/openai/nodes/RunThreadNode.ts b/packages/core/src/plugins/openai/nodes/RunThreadNode.ts index 546eda955..e95ebe803 100644 --- a/packages/core/src/plugins/openai/nodes/RunThreadNode.ts +++ b/packages/core/src/plugins/openai/nodes/RunThreadNode.ts @@ -286,11 +286,15 @@ export const RunThreadNodeImpl: PluginNodeImpl = { type: 'toggle', dataKey: 'useCodeInterpreterTool', label: 'Code Interpreter Tool Enabled', + helperMessage: + "Note: Only enabled if functions are provided. Otherwise, the assistant's settings will be used.", }, { type: 'toggle', dataKey: 'useRetrievalTool', label: 'Retrieval Tool Enabled', + helperMessage: + "Note: Only enabled if functions are provided. Otherwise, the assistant's settings will be used.", }, { type: 'custom', @@ -391,18 +395,21 @@ export const RunThreadNodeImpl: PluginNodeImpl = { const functionTools = coerceTypeOptional(inputData['functions' as PortId], 'gpt-function[]'); const tools = [...(functionTools?.map((f): OpenAIAssistantTool => ({ type: 'function', function: f })) ?? [])]; - if (data.useCodeInterpreterTool) { - tools.push({ type: 'code_interpreter' }); - } - if (data.useRetrievalTool) { - tools.push({ type: 'retrieval' }); + + if (tools.length) { + if (data.useCodeInterpreterTool) { + tools.push({ type: 'code_interpreter' }); + } + if (data.useRetrievalTool) { + tools.push({ type: 'retrieval' }); + } } const requestBody: CreateRunBody = { assistant_id: assistantId, model: getInputOrData(data, inputData, 'model'), instructions: getInputOrData(data, inputData, 'instructions'), - tools, + tools: tools.length > 0 ? tools : undefined, metadata, };