mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00

* refactor(addTitle): avoid generating title when a request was aborted * chore: bump openai to latest * fix: catch OpenAIError Uncaught error as last resort * fix: handle final messages excludes role=assistant * Update OpenAIClient.js * chore: fix linting errors
22 lines
589 B
JavaScript
22 lines
589 B
JavaScript
const { saveConvo } = require('~/models');
|
|
const { isEnabled } = require('~/server/utils');
|
|
|
|
const addTitle = async (req, { text, response, client }) => {
|
|
const { TITLE_CONVO = 'true' } = process.env ?? {};
|
|
if (!isEnabled(TITLE_CONVO)) {
|
|
return;
|
|
}
|
|
|
|
// If the request was aborted, don't generate the title.
|
|
if (client.abortController.signal.aborted) {
|
|
return;
|
|
}
|
|
|
|
const title = await client.titleConvo({ text, responseText: response?.text });
|
|
await saveConvo(req.user.id, {
|
|
conversationId: response.conversationId,
|
|
title,
|
|
});
|
|
};
|
|
|
|
module.exports = addTitle;
|