diff --git a/api/server/services/Threads/manage.js b/api/server/services/Threads/manage.js index 8dbac189a..f99dca753 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 493808925..2e05754ab 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]);