when waiting for LLM to response Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
This commit is contained in:
parent
e21cbc752a
commit
a9c3416236
@ -60,19 +60,21 @@ export const addOldMessagesAtom = atom(
|
|||||||
export const addNewMessageAtom = atom(
|
export const addNewMessageAtom = atom(
|
||||||
null,
|
null,
|
||||||
(get, set, newMessage: ThreadMessage) => {
|
(get, set, newMessage: ThreadMessage) => {
|
||||||
const threadId = get(getActiveThreadIdAtom)
|
const currentMessages = get(chatMessages)[newMessage.thread_id] ?? []
|
||||||
if (!threadId) return
|
|
||||||
|
|
||||||
const currentMessages = get(chatMessages)[threadId] ?? []
|
|
||||||
const updatedMessages = [...currentMessages, newMessage]
|
const updatedMessages = [...currentMessages, newMessage]
|
||||||
|
|
||||||
const newData: Record<string, ThreadMessage[]> = {
|
const newData: Record<string, ThreadMessage[]> = {
|
||||||
...get(chatMessages),
|
...get(chatMessages),
|
||||||
}
|
}
|
||||||
newData[threadId] = updatedMessages
|
newData[newMessage.thread_id] = updatedMessages
|
||||||
set(chatMessages, newData)
|
set(chatMessages, newData)
|
||||||
|
|
||||||
// Update thread last message
|
// Update thread last message
|
||||||
set(updateThreadStateLastMessageAtom, threadId, newMessage.content)
|
set(
|
||||||
|
updateThreadStateLastMessageAtom,
|
||||||
|
newMessage.thread_id,
|
||||||
|
newMessage.content
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user