mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
adds server and client error handling, clear convos in progress
This commit is contained in:
parent
511ac948b4
commit
51d93da3f8
9 changed files with 98 additions and 48 deletions
|
|
@ -27,25 +27,25 @@ const Conversation =
|
|||
|
||||
module.exports = {
|
||||
saveConvo: async ({ conversationId, parentMessageId, title }) => {
|
||||
const messages = await getMessages({ conversationId });
|
||||
const update = { parentMessageId, messages };
|
||||
if (title) {
|
||||
update.title = title;
|
||||
}
|
||||
try {
|
||||
const messages = await getMessages({ conversationId });
|
||||
const update = { parentMessageId, messages };
|
||||
if (title) {
|
||||
update.title = title;
|
||||
}
|
||||
|
||||
await Conversation.findOneAndUpdate(
|
||||
{ conversationId },
|
||||
{ $set: update },
|
||||
{ new: true, upsert: true }
|
||||
).exec();
|
||||
return await Conversation.findOneAndUpdate(
|
||||
{ conversationId },
|
||||
{ $set: update },
|
||||
{ new: true, upsert: true }
|
||||
).exec();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return { message: 'Error saving conversation' };
|
||||
}
|
||||
},
|
||||
getConvos: async () => await Conversation.find({}).exec(),
|
||||
deleteConvos: async (filter) => {
|
||||
// const filter = {};
|
||||
|
||||
// if (!!conversationId) {
|
||||
// filter = conversationId;
|
||||
// }
|
||||
|
||||
let deleteCount = await Conversation.deleteMany(filter).exec();
|
||||
deleteCount.messages = await deleteMessages(filter);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue