mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
commit
b1b904ce5a
3 changed files with 15 additions and 7 deletions
|
|
@ -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, updateConvo } = require('../../models');
|
const { saveBingMessage, getConvoTitle, saveConvo } = 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 updateConvo(
|
await saveConvo(
|
||||||
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 updateConvo(req?.session?.user?.username, { model, chatGptLabel: null, promptPrefix: null, ...convo, ...response });
|
await saveConvo(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,9 +161,11 @@ 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 updateConvo(
|
await saveConvo(
|
||||||
req?.session?.user?.username,
|
req?.session?.user?.username,
|
||||||
{
|
{
|
||||||
|
...convo,
|
||||||
|
...response,
|
||||||
conversationId,
|
conversationId,
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,17 @@ router.post('/gen_title', async (req, res) => {
|
||||||
|
|
||||||
router.post('/clear', async (req, res) => {
|
router.post('/clear', async (req, res) => {
|
||||||
let filter = {};
|
let filter = {};
|
||||||
const { conversationId } = req.body.arg;
|
const { conversationId, source } = req.body.arg;
|
||||||
if (conversationId) {
|
if (conversationId) {
|
||||||
filter = { conversationId };
|
filter = { conversationId };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('source:', source);
|
||||||
|
|
||||||
|
if (source === 'button' && !conversationId) {
|
||||||
|
return res.status(200).send('No conversationId provided');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dbResponse = await deleteConvos(req?.session?.user?.username, filter);
|
const dbResponse = await deleteConvos(req?.session?.user?.username, filter);
|
||||||
res.status(201).send(dbResponse);
|
res.status(201).send(dbResponse);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const clickHandler = () => trigger({ conversationId });
|
const clickHandler = () => trigger({ conversationId, source: 'button' });
|
||||||
const handler = renaming ? cancelHandler : clickHandler;
|
const handler = renaming ? cancelHandler : clickHandler;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue