mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 08:20:14 +01:00
* 🧹 chore: Update logger imports to use @librechat/data-schemas across multiple files and remove unused sleep function from queue.js (#9930) * chore: Replace local isEnabled utility with @librechat/api import across multiple files, update test files * chore: Replace local logger import with @librechat/data-schemas logger in countTokens.js and fork.js * chore: Update logs volume path in docker-compose.yml to correct directory * chore: import order of isEnabled in static.js
32 lines
884 B
JavaScript
32 lines
884 B
JavaScript
const { isEnabled } = require('@librechat/api');
|
|
const { CacheKeys } = require('librechat-data-provider');
|
|
const { saveConvo } = require('~/models/Conversation');
|
|
const getLogStores = require('~/cache/getLogStores');
|
|
|
|
const addTitle = async (req, { text, responseText, conversationId, client }) => {
|
|
const { TITLE_CONVO = 'true' } = process.env ?? {};
|
|
if (!isEnabled(TITLE_CONVO)) {
|
|
return;
|
|
}
|
|
|
|
if (client.options.titleConvo === false) {
|
|
return;
|
|
}
|
|
|
|
const titleCache = getLogStores(CacheKeys.GEN_TITLE);
|
|
const key = `${req.user.id}-${conversationId}`;
|
|
|
|
const title = await client.titleConvo({ text, conversationId, responseText });
|
|
await titleCache.set(key, title, 120000);
|
|
|
|
await saveConvo(
|
|
req,
|
|
{
|
|
conversationId,
|
|
title,
|
|
},
|
|
{ context: 'api/server/services/Endpoints/assistants/addTitle.js' },
|
|
);
|
|
};
|
|
|
|
module.exports = addTitle;
|