From 7de6bdcced205431b094d279faad74db0aa77a16 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 23 Dec 2024 14:29:50 +0700 Subject: [PATCH] fix: generating message is gone after switching to another thread --- web/helpers/atoms/ChatMessage.atom.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/helpers/atoms/ChatMessage.atom.ts b/web/helpers/atoms/ChatMessage.atom.ts index 5df44e0312..7034396652 100644 --- a/web/helpers/atoms/ChatMessage.atom.ts +++ b/web/helpers/atoms/ChatMessage.atom.ts @@ -175,6 +175,17 @@ export const updateMessageAtom = atom( // Update thread last message if (text.length) set(updateThreadStateLastMessageAtom, conversationId, text) + } else { + set(addNewMessageAtom, { + id, + thread_id: conversationId, + content: text, + status, + role: ChatCompletionRole.Assistant, + created_at: Date.now() / 1000, + completed_at: Date.now() / 1000, + object: 'thread.message', + }) } } )