From 1c05251826e7dd6e87851b3abc85a28bd31fbb2d Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 9 Dec 2024 08:38:39 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B5=20fix:=20Assistants=20API=20Thread?= =?UTF-8?q?=20ID=20Handling=20(#4912)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/server/services/Threads/manage.js | 2 +- client/src/hooks/Chat/useChatFunctions.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/server/services/Threads/manage.js b/api/server/services/Threads/manage.js index 8dbac189ab..f99dca7534 100644 --- a/api/server/services/Threads/manage.js +++ b/api/server/services/Threads/manage.js @@ -33,7 +33,7 @@ async function initThread({ openai, body, thread_id: _thread_id }) { thread = await openai.beta.threads.create(body); } - const thread_id = _thread_id ?? thread.id; + const thread_id = _thread_id || thread.id; return { messages, thread_id, ...thread }; } diff --git a/client/src/hooks/Chat/useChatFunctions.ts b/client/src/hooks/Chat/useChatFunctions.ts index 493808925e..2e05754ab5 100644 --- a/client/src/hooks/Chat/useChatFunctions.ts +++ b/client/src/hooks/Chat/useChatFunctions.ts @@ -138,9 +138,9 @@ export default function useChatFunctions({ (msg) => msg.messageId === latestMessage?.parentMessageId, ); - let thread_id = parentMessage?.thread_id ?? latestMessage?.thread_id ?? ''; - if (!thread_id) { - thread_id = currentMessages.find((message) => message.thread_id)?.thread_id ?? ''; + let thread_id = parentMessage?.thread_id ?? latestMessage?.thread_id; + if (thread_id == null) { + thread_id = currentMessages.find((message) => message.thread_id)?.thread_id; } const endpointsConfig = queryClient.getQueryData([QueryKeys.endpoints]);