mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
Rolled back to v0.0.2
This commit is contained in:
parent
57d3025717
commit
72ff47e204
20 changed files with 87 additions and 142 deletions
|
|
@ -1,32 +1,24 @@
|
|||
const { Configuration, OpenAIApi } = require('openai');
|
||||
|
||||
const titleConvo = async ({ message, response, model }) => {
|
||||
try {
|
||||
const configuration = new Configuration({
|
||||
apiKey: process.env.OPENAI_KEY
|
||||
});
|
||||
const openai = new OpenAIApi(configuration);
|
||||
const completion = await openai.createChatCompletion({
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: [
|
||||
{
|
||||
role: 'system',
|
||||
content:
|
||||
'You are a title-generator with one job: titling the conversation provided by a user in title case.'
|
||||
},
|
||||
{
|
||||
role: 'user',
|
||||
content: `In 5 words or less, summarize the conversation below with a title in title case. Don't refer to the participants of the conversation by name. Do not include punctuation or quotation marks. Your response should be in title case, exclusively containing the title. Conversation:\n\nUser: "${message}"\n\n${model}: "${response}"\n\nTitle: `
|
||||
}
|
||||
]
|
||||
});
|
||||
const configuration = new Configuration({
|
||||
apiKey: process.env.OPENAI_KEY
|
||||
});
|
||||
const openai = new OpenAIApi(configuration);
|
||||
const completion = await openai.createChatCompletion({
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: [
|
||||
{
|
||||
role: 'system',
|
||||
content:
|
||||
'You are a title-generator with one job: titling the conversation provided by a user in title case.'
|
||||
},
|
||||
{ role: 'user', content: `In 5 words or less, summarize the conversation below with a title in title case. Don't refer to the participants of the conversation by name. Do not include punctuation or quotation marks. Your response should be in title case, exclusively containing the title. Conversation:\n\nUser: "${message}"\n\n${model}: "${response}"\n\nTitle: ` },
|
||||
]
|
||||
});
|
||||
|
||||
//eslint-disable-next-line
|
||||
return completion.data.choices[0].message.content.replace(/["\.]/g, '');
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return 'New Chat';
|
||||
}
|
||||
//eslint-disable-next-line
|
||||
return completion.data.choices[0].message.content.replace(/["\.]/g, '');
|
||||
};
|
||||
|
||||
module.exports = titleConvo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue