File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -267,12 +267,12 @@ export const Chat = () => {
267267 // if this is the first message (of the assistant response to user message), then add the message to the conversation as 'assistant' message
268268 // else append the message to the exisiting assistant message (part of the stream appending)
269269 // look through the conversation messages and find if a assistant message has id = parentId
270- const assistantMessage = selectedConversation ?. messages ?. find ( ( msg ) => msg . role === 'assistant' && msg . parentId === message ?. parent_id )
271- if ( assistantMessage ) {
270+ const isLastMessageFromAssistant = selectedConversation ?. messages [ selectedConversation ?. messages ?. length - 1 ] . role === 'assistant'
271+ if ( isLastMessageFromAssistant ) {
272272 // console.log('found assistant message, appending to it')
273273 // update the assistant message inside selectedConversation
274- updatedMessages = selectedConversation ?. messages ?. map ( ( msg ) => {
275- if ( msg . role === 'assistant' && msg . parentId === message ?. parent_id ) {
274+ updatedMessages = selectedConversation ?. messages ?. map ( ( msg , idx ) => {
275+ if ( msg . role === 'assistant' && idx === selectedConversation ?. messages ?. length - 1 ) {
276276 // do this only for response token
277277 let updatedContent = msg . content || '' ;
278278 if ( message ?. type === webSocketMessageTypes . systemResponseMessage ) {
You can’t perform that action at this time.
0 commit comments