From a937650df60d5922987e64ef507fde961a5c9350 Mon Sep 17 00:00:00 2001 From: gjz <303796828@qq.com> Date: Thu, 23 May 2024 11:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix:=20Recognize=20`azureAssista?= =?UTF-8?q?nts`=20Endpoint=20Config=20(#2824)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix bug: azureAssistants endpoint config * refactor(assistants): make default value last * refactor(AppService): make assistantsConfigSetup potentially undefined value last arg * chore: Update JSDocs params assistants.js * Update assistants.js --------- Co-authored-by: 彭修照 Co-authored-by: Danny Avila --- api/server/services/AppService.js | 2 ++ api/server/services/start/assistants.js | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/server/services/AppService.js b/api/server/services/AppService.js index b4d35f1366..bbb3880b31 100644 --- a/api/server/services/AppService.js +++ b/api/server/services/AppService.js @@ -78,6 +78,7 @@ const AppService = async (app) => { if (config?.endpoints?.[EModelEndpoint.azureAssistants]) { endpointLocals[EModelEndpoint.azureAssistants] = assistantsConfigSetup( config, + EModelEndpoint.azureAssistants, endpointLocals[EModelEndpoint.azureAssistants], ); } @@ -85,6 +86,7 @@ const AppService = async (app) => { if (config?.endpoints?.[EModelEndpoint.assistants]) { endpointLocals[EModelEndpoint.assistants] = assistantsConfigSetup( config, + EModelEndpoint.assistants, endpointLocals[EModelEndpoint.assistants], ); } diff --git a/api/server/services/start/assistants.js b/api/server/services/start/assistants.js index 394d7d1a3e..eba6319f84 100644 --- a/api/server/services/start/assistants.js +++ b/api/server/services/start/assistants.js @@ -20,16 +20,17 @@ function azureAssistantsDefaults() { /** * Sets up the Assistants configuration from the config (`librechat.yaml`) file. * @param {TCustomConfig} config - The loaded custom configuration. - * @param {Partial} [prevConfig] + * @param {EModelEndpoint.assistants|EModelEndpoint.azureAssistants} assistantsEndpoint - The Assistants endpoint name. * - The previously loaded assistants configuration from Azure OpenAI Assistants option. + * @param {Partial} [prevConfig] * @returns {Partial} The Assistants endpoint configuration. */ -function assistantsConfigSetup(config, prevConfig = {}) { - const assistantsConfig = config.endpoints[EModelEndpoint.assistants]; +function assistantsConfigSetup(config, assistantsEndpoint, prevConfig = {}) { + const assistantsConfig = config.endpoints[assistantsEndpoint]; const parsedConfig = assistantEndpointSchema.parse(assistantsConfig); if (assistantsConfig.supportedIds?.length && assistantsConfig.excludedIds?.length) { logger.warn( - `Both \`supportedIds\` and \`excludedIds\` are defined for the ${EModelEndpoint.assistants} endpoint; \`excludedIds\` field will be ignored.`, + `Both \`supportedIds\` and \`excludedIds\` are defined for the ${assistantsEndpoint} endpoint; \`excludedIds\` field will be ignored.`, ); }