From 59109cd2dd4cfad47e119d8b9efab4392ad0a596 Mon Sep 17 00:00:00 2001 From: arthurolivierfortin <118319678+arthurolivierfortin@users.noreply.github.com> Date: Tue, 20 May 2025 08:43:12 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=AC=20fix:=20File=20Search=20Request?= =?UTF-8?q?=20Format=20(Azure=20Assistants=20API)=20(#7404)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: The request format for file analysis with Azure OpenAI assistants The request format for file analysis with Azure OpenAI assistants differs from that of OpenAI. This fix updates the API to use attachments instead of file_ids. danny-avila#7379 * chore: ESLint Error --------- Co-authored-by: Danny Avila --- api/server/controllers/assistants/chatV1.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/server/controllers/assistants/chatV1.js b/api/server/controllers/assistants/chatV1.js index 5fa10e9e37..9129a6a1c1 100644 --- a/api/server/controllers/assistants/chatV1.js +++ b/api/server/controllers/assistants/chatV1.js @@ -326,8 +326,15 @@ const chatV1 = async (req, res) => { file_ids = files.map(({ file_id }) => file_id); if (file_ids.length || thread_file_ids.length) { - userMessage.file_ids = file_ids; attachedFileIds = new Set([...file_ids, ...thread_file_ids]); + if (endpoint === EModelEndpoint.azureAssistants) { + userMessage.attachments = Array.from(attachedFileIds).map((file_id) => ({ + file_id, + tools: [{ type: 'file_search' }], + })); + } else { + userMessage.file_ids = Array.from(attachedFileIds); + } } };