mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-28 21:30:18 +01:00
chatgpt now titles conversations
This commit is contained in:
parent
897c384ac9
commit
c4d0787b49
4 changed files with 31 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
const { titleConvo } = require('./chatgpt');
|
||||
const titleConvo = require('./titleConvo');
|
||||
const { askClient } = require('./chatgpt-client');
|
||||
const { browserClient } = require('./chatgpt-browser');
|
||||
const { askBing } = require('./bingai');
|
||||
|
|
|
|||
23
app/titleConvo.js
Normal file
23
app/titleConvo.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
const { Configuration, OpenAIApi } = require('openai');
|
||||
|
||||
const titleConvo = async ({ message, response, model }) => {
|
||||
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 helpful title-generator with one job: titling in title case the conversation provided by a user. You do not reply with anything but a succinct title that summarizes the conversation in title case, ideally around 5 words or less. You do not refer to the participants of the conversation by name. Do not include punctuation or quotation marks.'
|
||||
},
|
||||
{ role: 'user', content: `Please title this conversation: User:"${message}" ${model}:"${response}"` },
|
||||
]
|
||||
});
|
||||
|
||||
return completion.data.choices[0].message.content;
|
||||
};
|
||||
|
||||
module.exports = titleConvo;
|
||||
Loading…
Add table
Add a link
Reference in a new issue