Skip to content

Commit

Permalink
🧵 fix: Assistants API Thread ID Handling (danny-avila#4912)
Browse files Browse the repository at this point in the history
  • Loading branch information
danny-avila authored Dec 9, 2024
1 parent cd1184a commit 1c05251
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/server/services/Threads/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/Chat/useChatFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TEndpointsConfig>([QueryKeys.endpoints]);
Expand Down

0 comments on commit 1c05251

Please sign in to comment.