Skip to content

Commit

Permalink
Do not always override an assistant's tools list in Run Thread node
Browse files Browse the repository at this point in the history
  • Loading branch information
abrenneke committed Jan 24, 2024
1 parent 08846b8 commit 1b534f8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/core/src/plugins/openai/nodes/RunThreadNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,15 @@ export const RunThreadNodeImpl: PluginNodeImpl<RunThreadNode> = {
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',
Expand Down Expand Up @@ -391,18 +395,21 @@ export const RunThreadNodeImpl: PluginNodeImpl<RunThreadNode> = {

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,
};

Expand Down

0 comments on commit 1b534f8

Please sign in to comment.