mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
feat(Message): add and handle isEdited property when edited/continued as this can include user input
This commit is contained in:
parent
cc260105ec
commit
327a69dba3
11 changed files with 17 additions and 41 deletions
|
|
@ -473,6 +473,7 @@ class BaseClient {
|
|||
conversationId,
|
||||
parentMessageId: userMessage.messageId,
|
||||
isCreatedByUser: false,
|
||||
isEdited,
|
||||
model: this.modelOptions.model,
|
||||
sender: this.sender,
|
||||
text: addSpaceIfNeeded(generation) + (await this.sendCompletion(payload, opts)),
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ class PluginsClient extends OpenAIClient {
|
|||
}
|
||||
const {
|
||||
user,
|
||||
isEdited,
|
||||
conversationId,
|
||||
responseMessageId,
|
||||
saveOptions,
|
||||
|
|
@ -293,6 +294,7 @@ class PluginsClient extends OpenAIClient {
|
|||
conversationId,
|
||||
parentMessageId: userMessage.messageId,
|
||||
isCreatedByUser: false,
|
||||
isEdited,
|
||||
model: this.modelOptions.model,
|
||||
sender: this.sender,
|
||||
promptTokens,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ module.exports = {
|
|||
error,
|
||||
unfinished,
|
||||
cancelled,
|
||||
isEdited = false,
|
||||
finish_reason = null,
|
||||
tokenCount = null,
|
||||
plugin = null,
|
||||
|
|
@ -34,6 +35,7 @@ module.exports = {
|
|||
sender,
|
||||
text,
|
||||
isCreatedByUser,
|
||||
isEdited,
|
||||
finish_reason,
|
||||
error,
|
||||
unfinished,
|
||||
|
|
@ -63,6 +65,7 @@ module.exports = {
|
|||
async updateMessage(message) {
|
||||
try {
|
||||
const { messageId, ...update } = message;
|
||||
update.isEdited = true;
|
||||
const updatedMessage = await Message.findOneAndUpdate({ messageId }, update, { new: true });
|
||||
|
||||
if (!updatedMessage) {
|
||||
|
|
@ -77,6 +80,7 @@ module.exports = {
|
|||
text: updatedMessage.text,
|
||||
isCreatedByUser: updatedMessage.isCreatedByUser,
|
||||
tokenCount: updatedMessage.tokenCount,
|
||||
isEdited: true,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(`Error updating message: ${err}`);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ const messageSchema = mongoose.Schema(
|
|||
required: true,
|
||||
default: false,
|
||||
},
|
||||
isEdited: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
unfinished: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ router.post(
|
|||
text: partialText,
|
||||
unfinished: true,
|
||||
cancelled: false,
|
||||
isEdited: true,
|
||||
error: false,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ router.post(
|
|||
model: endpointOption.modelOptions.model,
|
||||
unfinished: true,
|
||||
cancelled: false,
|
||||
isEdited: true,
|
||||
error: false,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ router.post(
|
|||
model: endpointOption.modelOptions.model,
|
||||
unfinished: true,
|
||||
cancelled: false,
|
||||
isEdited: true,
|
||||
error: false,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,47 +12,6 @@ const EModelEndpoint = {
|
|||
|
||||
const eModelEndpointSchema = z.nativeEnum(EModelEndpoint);
|
||||
|
||||
/*
|
||||
const tMessageSchema = z.object({
|
||||
messageId: z.string(),
|
||||
clientId: z.string().nullable().optional(),
|
||||
conversationId: z.string().nullable(),
|
||||
parentMessageId: z.string().nullable(),
|
||||
sender: z.string(),
|
||||
text: z.string(),
|
||||
isCreatedByUser: z.boolean(),
|
||||
error: z.boolean(),
|
||||
createdAt: z
|
||||
.string()
|
||||
.optional()
|
||||
.default(() => new Date().toISOString()),
|
||||
updatedAt: z
|
||||
.string()
|
||||
.optional()
|
||||
.default(() => new Date().toISOString()),
|
||||
current: z.boolean().optional(),
|
||||
unfinished: z.boolean().optional(),
|
||||
submitting: z.boolean().optional(),
|
||||
searchResult: z.boolean().optional(),
|
||||
finish_reason: z.string().optional(),
|
||||
});
|
||||
|
||||
const tPresetSchema = tConversationSchema
|
||||
.omit({
|
||||
conversationId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
title: true,
|
||||
})
|
||||
.merge(
|
||||
z.object({
|
||||
conversationId: z.string().optional(),
|
||||
presetId: z.string().nullable().optional(),
|
||||
title: z.string().nullable().optional(),
|
||||
}),
|
||||
);
|
||||
*/
|
||||
|
||||
const tPluginAuthConfigSchema = z.object({
|
||||
authField: z.string(),
|
||||
label: z.string(),
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ const EditMessage = ({
|
|||
? {
|
||||
...msg,
|
||||
text,
|
||||
isEdited: true,
|
||||
}
|
||||
: msg,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ const useMessageHandler = () => {
|
|||
unfinished: false,
|
||||
submitting: true,
|
||||
isCreatedByUser: false,
|
||||
isEdited: isEditOrContinue,
|
||||
error: false,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ export const tMessageSchema = z.object({
|
|||
sender: z.string(),
|
||||
text: z.string(),
|
||||
generation: z.string().nullable().optional(),
|
||||
isEdited: z.boolean().optional(),
|
||||
isCreatedByUser: z.boolean(),
|
||||
error: z.boolean(),
|
||||
createdAt: z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue