mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50: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;
|
update.promptPrefix = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(user)
|
|
||||||
|
|
||||||
return await Conversation.findOneAndUpdate(
|
return await Conversation.findOneAndUpdate(
|
||||||
{ conversationId: conversationId, user: user },
|
{ conversationId: conversationId, user: user },
|
||||||
{ $set: update },
|
{ $set: update },
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ router.post('/', async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await saveMessage(userMessage);
|
await saveMessage(userMessage);
|
||||||
await saveConvo({ ...userMessage, model, ...convo });
|
await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
|
||||||
|
|
||||||
return await ask({
|
return await ask({
|
||||||
userMessage,
|
userMessage,
|
||||||
|
|
@ -178,7 +178,7 @@ const ask = async ({
|
||||||
await saveMessage(gptResponse);
|
await saveMessage(gptResponse);
|
||||||
await saveConvo(req?.session?.user?.username, gptResponse);
|
await saveConvo(req?.session?.user?.username, gptResponse);
|
||||||
sendMessage(res, {
|
sendMessage(res, {
|
||||||
title: await getConvoTitle(conversationId),
|
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||||
final: true,
|
final: true,
|
||||||
requestMessage: userMessage,
|
requestMessage: userMessage,
|
||||||
responseMessage: gptResponse
|
responseMessage: gptResponse
|
||||||
|
|
@ -188,10 +188,13 @@ const ask = async ({
|
||||||
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||||
const title = await titleConvo({ model, text, response: gptResponse });
|
const title = await titleConvo({ model, text, response: gptResponse });
|
||||||
|
|
||||||
await saveConvo({
|
await saveConvo(
|
||||||
conversationId,
|
req?.session?.user?.username,
|
||||||
title
|
{
|
||||||
});
|
conversationId,
|
||||||
|
title
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ router.post('/', async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await saveMessage(userMessage);
|
await saveMessage(userMessage);
|
||||||
await saveConvo({ ...userMessage, model, ...convo });
|
await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
|
||||||
|
|
||||||
return await ask({
|
return await ask({
|
||||||
isNewConversation,
|
isNewConversation,
|
||||||
|
|
@ -108,10 +108,13 @@ const ask = async ({
|
||||||
// Attition: the api will also create new conversationId while using invalid userMessage.parentMessageId,
|
// 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.
|
// but in this situation, don't change the conversationId, but create new convo.
|
||||||
if (conversationId != userMessage.conversationId && isNewConversation)
|
if (conversationId != userMessage.conversationId && isNewConversation)
|
||||||
await saveConvo({
|
await saveConvo(
|
||||||
conversationId: conversationId,
|
req?.session?.user?.username,
|
||||||
newConversationId: userMessage.conversationId
|
{
|
||||||
});
|
conversationId: conversationId,
|
||||||
|
newConversationId: userMessage.conversationId
|
||||||
|
}
|
||||||
|
);
|
||||||
conversationId = userMessage.conversationId;
|
conversationId = userMessage.conversationId;
|
||||||
|
|
||||||
response.text = response.response;
|
response.text = response.response;
|
||||||
|
|
@ -132,7 +135,7 @@ const ask = async ({
|
||||||
await saveConvo(req?.session?.user?.username, { ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
|
await saveConvo(req?.session?.user?.username, { ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
|
||||||
|
|
||||||
sendMessage(res, {
|
sendMessage(res, {
|
||||||
title: await getConvoTitle(conversationId),
|
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||||
final: true,
|
final: true,
|
||||||
requestMessage: userMessage,
|
requestMessage: userMessage,
|
||||||
responseMessage: response
|
responseMessage: response
|
||||||
|
|
@ -142,10 +145,13 @@ const ask = async ({
|
||||||
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||||
const title = await titleConvo({ model, text, response });
|
const title = await titleConvo({ model, text, response });
|
||||||
|
|
||||||
await saveConvo({
|
await saveConvo(
|
||||||
conversationId,
|
req?.session?.user?.username,
|
||||||
title
|
{
|
||||||
});
|
conversationId,
|
||||||
|
title
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ router.post('/', async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await saveMessage(userMessage);
|
await saveMessage(userMessage);
|
||||||
await saveConvo({ ...userMessage, model, ...convo });
|
await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
|
||||||
|
|
||||||
return await ask({
|
return await ask({
|
||||||
isNewConversation,
|
isNewConversation,
|
||||||
|
|
@ -132,10 +132,13 @@ const ask = async ({
|
||||||
// Attition: the api will also create new conversationId while using invalid userMessage.parentMessageId,
|
// 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.
|
// but in this situation, don't change the conversationId, but create new convo.
|
||||||
if (conversationId != userMessage.conversationId && isNewConversation)
|
if (conversationId != userMessage.conversationId && isNewConversation)
|
||||||
await saveConvo({
|
await saveConvo(
|
||||||
conversationId: conversationId,
|
req?.session?.user?.username,
|
||||||
newConversationId: userMessage.conversationId
|
{
|
||||||
});
|
conversationId: conversationId,
|
||||||
|
newConversationId: userMessage.conversationId
|
||||||
|
}
|
||||||
|
);
|
||||||
conversationId = userMessage.conversationId;
|
conversationId = userMessage.conversationId;
|
||||||
|
|
||||||
response.text = await handleText(response, true);
|
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 });
|
await saveConvo(req?.session?.user?.username, { ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
|
||||||
|
|
||||||
sendMessage(res, {
|
sendMessage(res, {
|
||||||
title: await getConvoTitle(conversationId),
|
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||||
final: true,
|
final: true,
|
||||||
requestMessage: userMessage,
|
requestMessage: userMessage,
|
||||||
responseMessage: response
|
responseMessage: response
|
||||||
|
|
@ -154,10 +157,13 @@ const ask = async ({
|
||||||
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||||
const title = await titleConvo({ model, text, response });
|
const title = await titleConvo({ model, text, response });
|
||||||
|
|
||||||
await saveConvo({
|
await saveConvo(
|
||||||
conversationId,
|
req?.session?.user?.username,
|
||||||
title
|
{
|
||||||
});
|
conversationId,
|
||||||
|
title
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,18 @@ router.post('/gen_title', async (req, res) => {
|
||||||
const secondMessage = (await getMessages({ conversationId }))[1]
|
const secondMessage = (await getMessages({ conversationId }))[1]
|
||||||
|
|
||||||
const title = convo.jailbreakConversationId
|
const title = convo.jailbreakConversationId
|
||||||
? await getConvoTitle(conversationId)
|
? await getConvoTitle(req?.session?.user?.username, conversationId)
|
||||||
: await titleConvo({
|
: await titleConvo({
|
||||||
model: convo?.model,
|
model: convo?.model,
|
||||||
message: firstMessage?.text,
|
message: firstMessage?.text,
|
||||||
response: JSON.stringify(secondMessage?.text || '')
|
response: JSON.stringify(secondMessage?.text || '')
|
||||||
});
|
});
|
||||||
|
|
||||||
await saveConvo(req?.session?.user?.username,
|
await saveConvo(
|
||||||
|
req?.session?.user?.username,
|
||||||
{
|
{
|
||||||
conversationId,
|
conversationId,
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue