mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-21 21:50:49 +02:00
fix: isEdited edge case where latest Message is not saved due to aborting too quickly
This commit is contained in:
parent
ae5c06f381
commit
39c626aa8e
1 changed files with 15 additions and 2 deletions
|
@ -412,8 +412,21 @@ class BaseClient {
|
||||||
// depending on subclass implementation of handling messages
|
// depending on subclass implementation of handling messages
|
||||||
// When this is an edit, all messages are already in currentMessages, both user and response
|
// When this is an edit, all messages are already in currentMessages, both user and response
|
||||||
if (isEdited) {
|
if (isEdited) {
|
||||||
/* TODO: edge case where latest message doesn't exist */
|
let latestMessage = this.currentMessages[this.currentMessages.length - 1];
|
||||||
this.currentMessages[this.currentMessages.length - 1].text = generation;
|
if (!latestMessage) {
|
||||||
|
latestMessage = {
|
||||||
|
messageId: responseMessageId,
|
||||||
|
conversationId,
|
||||||
|
parentMessageId: userMessage.messageId,
|
||||||
|
isCreatedByUser: false,
|
||||||
|
model: this.modelOptions.model,
|
||||||
|
sender: this.sender,
|
||||||
|
text: generation,
|
||||||
|
};
|
||||||
|
this.currentMessages.push(userMessage, latestMessage);
|
||||||
|
} else {
|
||||||
|
latestMessage.text = generation;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.currentMessages.push(userMessage);
|
this.currentMessages.push(userMessage);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue