From 0a1d38e3189a4f905d021be41ac2c8b5bd03d8b7 Mon Sep 17 00:00:00 2001 From: Benedikt Nordhoff Date: Fri, 12 Jul 2024 14:26:35 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix:=20Make=20assistant=20tool?= =?UTF-8?q?=20filtering=20compatible=20with=20plugin=20filtering=20(#3325)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit includedTools expects the pluginKey/tool.name for filtering included tools, which is incompatible with the previous implementation in loadAndFormatTools used for loading assistant tools. This change uses both filename and tool.name for filtering tools in ToolService.loadAndFormatTools in order to make it compatible with the old implementation and the behaviour of plugin filtering. Co-authored-by: Benedikt Nordhoff --- api/server/services/ToolService.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/server/services/ToolService.js b/api/server/services/ToolService.js index 524797d062..a91948b19a 100644 --- a/api/server/services/ToolService.js +++ b/api/server/services/ToolService.js @@ -73,10 +73,6 @@ function loadAndFormatTools({ directory, adminFilter = [], adminIncluded = [] }) continue; } - if (included.size > 0 && !included.has(file)) { - continue; - } - let toolInstance = null; try { toolInstance = new ToolClass({ override: true }); @@ -92,6 +88,14 @@ function loadAndFormatTools({ directory, adminFilter = [], adminIncluded = [] }) continue; } + if (filter.has(toolInstance.name) && included.size === 0) { + continue; + } + + if (included.size > 0 && !included.has(file) && !included.has(toolInstance.name)) { + continue; + } + const formattedTool = formatToOpenAIAssistantTool(toolInstance); tools.push(formattedTool); }