🔧 fix: Make assistant tool filtering compatible with plugin filtering (#3325)

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 <benedikt.nordhoff@codecentric.de>
This commit is contained in:
Benedikt Nordhoff 2024-07-12 14:26:35 +02:00 committed by GitHub
parent 5ef71a7a36
commit 0a1d38e318
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}