mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
updateConvo for title updating
This commit is contained in:
parent
e8e512a451
commit
7486a56816
4 changed files with 13 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
const { getMessages, saveMessage, saveBingMessage, deleteMessagesSince, deleteMessages } = require('./Message');
|
const { getMessages, saveMessage, saveBingMessage, deleteMessagesSince, deleteMessages } = require('./Message');
|
||||||
const { getCustomGpts, updateCustomGpt, updateByLabel, deleteCustomGpts } = require('./CustomGpt');
|
const { getCustomGpts, updateCustomGpt, updateByLabel, deleteCustomGpts } = require('./CustomGpt');
|
||||||
const { getConvoTitle, getConvo, saveConvo } = require('./Conversation');
|
const { getConvoTitle, getConvo, saveConvo, updateConvo } = require('./Conversation');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getMessages,
|
getMessages,
|
||||||
|
|
@ -11,6 +11,7 @@ module.exports = {
|
||||||
getConvoTitle,
|
getConvoTitle,
|
||||||
getConvo,
|
getConvo,
|
||||||
saveConvo,
|
saveConvo,
|
||||||
|
updateConvo,
|
||||||
getCustomGpts,
|
getCustomGpts,
|
||||||
updateCustomGpt,
|
updateCustomGpt,
|
||||||
updateByLabel,
|
updateByLabel,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ const router = express.Router();
|
||||||
const askBing = require('./askBing');
|
const askBing = require('./askBing');
|
||||||
const askSydney = require('./askSydney');
|
const askSydney = require('./askSydney');
|
||||||
const { titleConvo, askClient, browserClient, customClient } = require('../../app/');
|
const { titleConvo, askClient, browserClient, customClient } = require('../../app/');
|
||||||
const { getConvo, saveMessage, getConvoTitle, saveConvo } = require('../../models');
|
const { getConvo, saveMessage, getConvoTitle, saveConvo, updateConvo } = require('../../models');
|
||||||
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
|
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
|
||||||
const { getMessages } = require('../../models/Message');
|
const { getMessages } = require('../../models/Message');
|
||||||
|
|
||||||
|
|
@ -169,7 +169,7 @@ const ask = async ({
|
||||||
}
|
}
|
||||||
|
|
||||||
await saveMessage(gptResponse);
|
await saveMessage(gptResponse);
|
||||||
await saveConvo(req?.session?.user?.username, gptResponse);
|
await updateConvo(req?.session?.user?.username, gptResponse);
|
||||||
sendMessage(res, {
|
sendMessage(res, {
|
||||||
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||||
final: true,
|
final: true,
|
||||||
|
|
@ -181,7 +181,7 @@ 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 updateConvo(
|
||||||
req?.session?.user?.username,
|
req?.session?.user?.username,
|
||||||
{
|
{
|
||||||
/* again, for sake of browser client, will soon refactor */
|
/* again, for sake of browser client, will soon refactor */
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const express = require('express');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const { titleConvo, askBing } = require('../../app/');
|
const { titleConvo, askBing } = require('../../app/');
|
||||||
const { saveBingMessage, getConvoTitle, saveConvo } = require('../../models');
|
const { saveBingMessage, getConvoTitle, saveConvo, updateConvo } = require('../../models');
|
||||||
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
|
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
|
||||||
|
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
|
|
@ -123,7 +123,7 @@ 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 updateConvo(
|
||||||
req?.session?.user?.username,
|
req?.session?.user?.username,
|
||||||
{
|
{
|
||||||
conversationId: conversationId,
|
conversationId: conversationId,
|
||||||
|
|
@ -148,7 +148,7 @@ const ask = async ({
|
||||||
|
|
||||||
response.text = await handleText(response, true);
|
response.text = await handleText(response, true);
|
||||||
await saveBingMessage(response);
|
await saveBingMessage(response);
|
||||||
await saveConvo(req?.session?.user?.username, { model, chatGptLabel: null, promptPrefix: null, ...convo, ...response });
|
await updateConvo(req?.session?.user?.username, { model, chatGptLabel: null, promptPrefix: null, ...convo, ...response });
|
||||||
|
|
||||||
sendMessage(res, {
|
sendMessage(res, {
|
||||||
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||||
|
|
@ -161,11 +161,9 @@ 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 updateConvo(
|
||||||
req?.session?.user?.username,
|
req?.session?.user?.username,
|
||||||
{
|
{
|
||||||
...convo,
|
|
||||||
...response,
|
|
||||||
conversationId,
|
conversationId,
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const express = require('express');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const { titleConvo, askSydney } = require('../../app/');
|
const { titleConvo, askSydney } = require('../../app/');
|
||||||
const { saveBingMessage, saveConvo, getConvoTitle } = require('../../models');
|
const { saveBingMessage, saveConvo, updateConvo, getConvoTitle } = require('../../models');
|
||||||
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
|
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
|
||||||
|
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
|
|
@ -146,7 +146,7 @@ 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 updateConvo(
|
||||||
req?.session?.user?.username,
|
req?.session?.user?.username,
|
||||||
{
|
{
|
||||||
conversationId: conversationId,
|
conversationId: conversationId,
|
||||||
|
|
@ -158,7 +158,7 @@ const ask = async ({
|
||||||
response.text = await handleText(response, true);
|
response.text = await handleText(response, true);
|
||||||
// Save sydney response & convo, then send
|
// Save sydney response & convo, then send
|
||||||
await saveBingMessage(response);
|
await saveBingMessage(response);
|
||||||
await saveConvo(req?.session?.user?.username, { model, chatGptLabel: null, promptPrefix: null, ...convo, ...response });
|
await updateConvo(req?.session?.user?.username, { model, chatGptLabel: null, promptPrefix: null, ...convo, ...response });
|
||||||
|
|
||||||
sendMessage(res, {
|
sendMessage(res, {
|
||||||
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
title: await getConvoTitle(req?.session?.user?.username, conversationId),
|
||||||
|
|
@ -171,11 +171,9 @@ 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 updateConvo(
|
||||||
req?.session?.user?.username,
|
req?.session?.user?.username,
|
||||||
{
|
{
|
||||||
...convo,
|
|
||||||
...response,
|
|
||||||
conversationId,
|
conversationId,
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue