mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
fix: debounce title request and handle error with default title
This commit is contained in:
parent
96ca783517
commit
2fd50c99b8
7 changed files with 70 additions and 100 deletions
|
|
@ -1,4 +1,4 @@
|
|||
const { citeText, detectCode } = require('../../app/');
|
||||
const { titleConvo, citeText, detectCode } = require('../../app/');
|
||||
const _ = require('lodash');
|
||||
const sanitizeHtml = require('sanitize-html');
|
||||
|
||||
|
|
@ -14,6 +14,23 @@ const sendMessage = (res, message) => {
|
|||
res.write(`event: message\ndata: ${JSON.stringify(message)}\n\n`);
|
||||
};
|
||||
|
||||
const genTitle = async ({ model, text, response }) => {
|
||||
let title = 'New Chat';
|
||||
try {
|
||||
title = await titleConvo({
|
||||
model,
|
||||
message: text,
|
||||
response: JSON.stringify(response?.text)
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.log('There was an issue generating title, see error above');
|
||||
}
|
||||
|
||||
console.log('CONVERSATION TITLE', title);
|
||||
return title;
|
||||
};
|
||||
|
||||
const createOnProgress = () => {
|
||||
let i = 0;
|
||||
let tokens = '';
|
||||
|
|
@ -56,4 +73,4 @@ const handleText = async (input) => {
|
|||
return text;
|
||||
};
|
||||
|
||||
module.exports = { handleError, sendMessage, createOnProgress, handleText };
|
||||
module.exports = { handleError, sendMessage, createOnProgress, genTitle, handleText };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue