mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
* feat: add option to disable titling as well as decide what model to use for OpenAI titling refactor: truncate conversation text so it caps around 200 tokens for titling requests, optimize some of the title prompts * feat: disable bing titling with TITLE_CONVO as well
33 lines
957 B
JavaScript
33 lines
957 B
JavaScript
const {
|
|
ChatPromptTemplate,
|
|
SystemMessagePromptTemplate,
|
|
HumanMessagePromptTemplate,
|
|
} = require('langchain/prompts');
|
|
|
|
const langPrompt = new ChatPromptTemplate({
|
|
promptMessages: [
|
|
SystemMessagePromptTemplate.fromTemplate('Detect the language used in the following text.'),
|
|
HumanMessagePromptTemplate.fromTemplate('{inputText}'),
|
|
],
|
|
inputVariables: ['inputText'],
|
|
});
|
|
|
|
const createTitlePrompt = ({ convo }) => {
|
|
const titlePrompt = new ChatPromptTemplate({
|
|
promptMessages: [
|
|
SystemMessagePromptTemplate.fromTemplate(
|
|
`Write a concise title for this conversation in the given language. Title in 5 Words or Less. No Punctuation or Quotation. Must be in Title Case, written in the given Language.
|
|
${convo}`,
|
|
),
|
|
HumanMessagePromptTemplate.fromTemplate('Language: {language}'),
|
|
],
|
|
inputVariables: ['language'],
|
|
});
|
|
|
|
return titlePrompt;
|
|
};
|
|
|
|
module.exports = {
|
|
langPrompt,
|
|
createTitlePrompt,
|
|
};
|