mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
sync updates and merge with feat-resubmit
This commit is contained in:
parent
62d88380e0
commit
b0284b6974
5 changed files with 46 additions and 32 deletions
|
|
@ -85,8 +85,6 @@ module.exports = {
|
|||
update.promptPrefix = null;
|
||||
}
|
||||
|
||||
console.error(user)
|
||||
|
||||
return await Conversation.findOneAndUpdate(
|
||||
{ conversationId: conversationId, user: user },
|
||||
{ $set: update },
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ router.post('/', async (req, res) => {
|
|||
});
|
||||
|
||||
await saveMessage(userMessage);
|
||||
await saveConvo({ ...userMessage, model, ...convo });
|
||||
await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
|
||||
|
||||
return await ask({
|
||||
userMessage,
|
||||
|
|
@ -178,7 +178,7 @@ const ask = async ({
|
|||
await saveMessage(gptResponse);
|
||||
await saveConvo(req?.session?.user?.username, gptResponse);
|
||||
sendMessage(res, {
|
||||
title: await getConvoTitle(conversationId),
|
||||
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||
final: true,
|
||||
requestMessage: userMessage,
|
||||
responseMessage: gptResponse
|
||||
|
|
@ -188,10 +188,13 @@ const ask = async ({
|
|||
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||
const title = await titleConvo({ model, text, response: gptResponse });
|
||||
|
||||
await saveConvo({
|
||||
conversationId,
|
||||
title
|
||||
});
|
||||
await saveConvo(
|
||||
req?.session?.user?.username,
|
||||
{
|
||||
conversationId,
|
||||
title
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ router.post('/', async (req, res) => {
|
|||
});
|
||||
|
||||
await saveMessage(userMessage);
|
||||
await saveConvo({ ...userMessage, model, ...convo });
|
||||
await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
|
||||
|
||||
return await ask({
|
||||
isNewConversation,
|
||||
|
|
@ -108,10 +108,13 @@ const ask = async ({
|
|||
// Attition: the api will also create new conversationId while using invalid userMessage.parentMessageId,
|
||||
// but in this situation, don't change the conversationId, but create new convo.
|
||||
if (conversationId != userMessage.conversationId && isNewConversation)
|
||||
await saveConvo({
|
||||
conversationId: conversationId,
|
||||
newConversationId: userMessage.conversationId
|
||||
});
|
||||
await saveConvo(
|
||||
req?.session?.user?.username,
|
||||
{
|
||||
conversationId: conversationId,
|
||||
newConversationId: userMessage.conversationId
|
||||
}
|
||||
);
|
||||
conversationId = userMessage.conversationId;
|
||||
|
||||
response.text = response.response;
|
||||
|
|
@ -132,7 +135,7 @@ const ask = async ({
|
|||
await saveConvo(req?.session?.user?.username, { ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
|
||||
|
||||
sendMessage(res, {
|
||||
title: await getConvoTitle(conversationId),
|
||||
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||
final: true,
|
||||
requestMessage: userMessage,
|
||||
responseMessage: response
|
||||
|
|
@ -142,10 +145,13 @@ const ask = async ({
|
|||
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||
const title = await titleConvo({ model, text, response });
|
||||
|
||||
await saveConvo({
|
||||
conversationId,
|
||||
title
|
||||
});
|
||||
await saveConvo(
|
||||
req?.session?.user?.username,
|
||||
{
|
||||
conversationId,
|
||||
title
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ router.post('/', async (req, res) => {
|
|||
});
|
||||
|
||||
await saveMessage(userMessage);
|
||||
await saveConvo({ ...userMessage, model, ...convo });
|
||||
await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
|
||||
|
||||
return await ask({
|
||||
isNewConversation,
|
||||
|
|
@ -132,10 +132,13 @@ const ask = async ({
|
|||
// Attition: the api will also create new conversationId while using invalid userMessage.parentMessageId,
|
||||
// but in this situation, don't change the conversationId, but create new convo.
|
||||
if (conversationId != userMessage.conversationId && isNewConversation)
|
||||
await saveConvo({
|
||||
conversationId: conversationId,
|
||||
newConversationId: userMessage.conversationId
|
||||
});
|
||||
await saveConvo(
|
||||
req?.session?.user?.username,
|
||||
{
|
||||
conversationId: conversationId,
|
||||
newConversationId: userMessage.conversationId
|
||||
}
|
||||
);
|
||||
conversationId = userMessage.conversationId;
|
||||
|
||||
response.text = await handleText(response, true);
|
||||
|
|
@ -144,7 +147,7 @@ const ask = async ({
|
|||
await saveConvo(req?.session?.user?.username, { ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
|
||||
|
||||
sendMessage(res, {
|
||||
title: await getConvoTitle(conversationId),
|
||||
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||
final: true,
|
||||
requestMessage: userMessage,
|
||||
responseMessage: response
|
||||
|
|
@ -154,10 +157,13 @@ const ask = async ({
|
|||
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||
const title = await titleConvo({ model, text, response });
|
||||
|
||||
await saveConvo({
|
||||
conversationId,
|
||||
title
|
||||
});
|
||||
await saveConvo(
|
||||
req?.session?.user?.username,
|
||||
{
|
||||
conversationId,
|
||||
title
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
|
|
@ -18,17 +18,18 @@ router.post('/gen_title', async (req, res) => {
|
|||
const secondMessage = (await getMessages({ conversationId }))[1]
|
||||
|
||||
const title = convo.jailbreakConversationId
|
||||
? await getConvoTitle(conversationId)
|
||||
? await getConvoTitle(req?.session?.user?.username, conversationId)
|
||||
: await titleConvo({
|
||||
model: convo?.model,
|
||||
message: firstMessage?.text,
|
||||
response: JSON.stringify(secondMessage?.text || '')
|
||||
});
|
||||
|
||||
await saveConvo(req?.session?.user?.username,
|
||||
await saveConvo(
|
||||
req?.session?.user?.username,
|
||||
{
|
||||
conversationId,
|
||||
title
|
||||
conversationId,
|
||||
title
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue