From 8920490f387aa833793ff508f56eed041341e3fb Mon Sep 17 00:00:00 2001 From: Andres Restrepo Date: Wed, 18 Dec 2024 23:18:01 +0000 Subject: [PATCH] chore: openai client is not necessarily present when deleting files from azure --- api/server/services/Files/process.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/api/server/services/Files/process.js b/api/server/services/Files/process.js index 709b2a5ce44..1dcd805fb4e 100644 --- a/api/server/services/Files/process.js +++ b/api/server/services/Files/process.js @@ -135,21 +135,29 @@ const processDeleteRequest = async ({ req, files }) => { /** @type {Record} */ const client = { [FileSources.openai]: undefined, [FileSources.azure]: undefined }; const initializeClients = async () => { - const openAIClient = await getOpenAIClient({ - req, - overrideEndpoint: EModelEndpoint.assistants, - }); - client[FileSources.openai] = openAIClient.openai; + try { + const openAIClient = await getOpenAIClient({ + req, + overrideEndpoint: EModelEndpoint.assistants, + }); + client[FileSources.openai] = openAIClient.openai; + } catch (error) { + logger.warn(`Could not init OpenAI client: ${error}`); + } if (!req.app.locals[EModelEndpoint.azureOpenAI]?.assistants) { return; } - const azureClient = await getOpenAIClient({ - req, - overrideEndpoint: EModelEndpoint.azureAssistants, - }); - client[FileSources.azure] = azureClient.openai; + try { + const azureClient = await getOpenAIClient({ + req, + overrideEndpoint: EModelEndpoint.azureAssistants, + }); + client[FileSources.azure] = azureClient.openai; + } catch (error) { + logger.warn(`Could not init Azure OpenAI client: ${error}`); + } }; if (req.body.assistant_id !== undefined) {