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

* refactor: use parseCompactConvo in buildOptions, and generate no default values for the API to avoid weird model behavior with defaults * refactor: OTHER - always show cursor when markdown component is empty (preferable to not) * refactor(OpenAISettings): use config object for setting defaults app-wide * refactor: Use removeNullishValues in buildOptions for ALL endpoints * fix: add missing conversationId to title methods for transactions; refactor(GoogleClient): model options, set no default, add todo note for recording token usage * fix: at minimum set a model default, as is required by API (edge case)
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
const { CacheKeys } = require('librechat-data-provider');
|
|
const getLogStores = require('~/cache/getLogStores');
|
|
const { isEnabled } = require('~/server/utils');
|
|
const { saveConvo } = require('~/models');
|
|
|
|
const addTitle = async (req, { text, response, client }) => {
|
|
const { TITLE_CONVO = 'true' } = process.env ?? {};
|
|
if (!isEnabled(TITLE_CONVO)) {
|
|
return;
|
|
}
|
|
|
|
if (client.options.titleConvo === false) {
|
|
return;
|
|
}
|
|
|
|
// If the request was aborted and is not azure, don't generate the title.
|
|
if (!client.azure && client.abortController.signal.aborted) {
|
|
return;
|
|
}
|
|
|
|
const titleCache = getLogStores(CacheKeys.GEN_TITLE);
|
|
const key = `${req.user.id}-${response.conversationId}`;
|
|
|
|
const title = await client.titleConvo({
|
|
text,
|
|
responseText: response?.text,
|
|
conversationId: response.conversationId,
|
|
});
|
|
await titleCache.set(key, title, 120000);
|
|
await saveConvo(
|
|
req,
|
|
{
|
|
conversationId: response.conversationId,
|
|
title,
|
|
},
|
|
{ context: 'api/server/services/Endpoints/openAI/addTitle.js' },
|
|
);
|
|
};
|
|
|
|
module.exports = addTitle;
|