mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-08 18:44:22 +01:00
complete customChatGpt model selection
This commit is contained in:
parent
0f9cfd0395
commit
214228542a
18 changed files with 742 additions and 63 deletions
37
app/chatgpt-custom.js
Normal file
37
app/chatgpt-custom.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
require('dotenv').config();
|
||||
const { KeyvFile } = require('keyv-file');
|
||||
|
||||
const clientOptions = {
|
||||
modelOptions: {
|
||||
model: 'gpt-3.5-turbo'
|
||||
},
|
||||
debug: false
|
||||
};
|
||||
|
||||
const customClient = async ({ text, progressCallback, convo, promptPrefix, chatGptLabel }) => {
|
||||
const ChatGPTClient = (await import('@waylaidwanderer/chatgpt-api')).default;
|
||||
const store = {
|
||||
store: new KeyvFile({ filename: './data/cache.json' })
|
||||
};
|
||||
|
||||
clientOptions.chatGptLabel = chatGptLabel;
|
||||
|
||||
if (promptPrefix.length > 0) {
|
||||
clientOptions.promptPrefix = promptPrefix;
|
||||
}
|
||||
|
||||
const client = new ChatGPTClient(process.env.OPENAI_KEY, clientOptions, store);
|
||||
|
||||
let options = {
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes)
|
||||
};
|
||||
|
||||
if (!!convo.parentMessageId && !!convo.conversationId) {
|
||||
options = { ...options, ...convo };
|
||||
}
|
||||
|
||||
const res = await client.sendMessage(text, options);
|
||||
return res;
|
||||
};
|
||||
|
||||
module.exports = customClient;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
const { askClient } = require('./chatgpt-client');
|
||||
const { browserClient } = require('./chatgpt-browser');
|
||||
const customClient = require('./chatgpt-custom');
|
||||
const { askBing } = require('./bingai');
|
||||
const titleConvo = require('./titleConvo');
|
||||
const detectCode = require('./detectCode');
|
||||
|
|
@ -7,6 +8,7 @@ const detectCode = require('./detectCode');
|
|||
module.exports = {
|
||||
askClient,
|
||||
browserClient,
|
||||
customClient,
|
||||
askBing,
|
||||
titleConvo,
|
||||
detectCode
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ const titleConvo = async ({ message, response, model }) => {
|
|||
{
|
||||
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. Your response should be in title case, exclusively containing the title.'
|
||||
'You are a title-generator with one job: titling the conversation provided by a user in title case.'
|
||||
},
|
||||
{ role: 'user', content: `Please title this conversation: User:"${message}" ${model}:"${response}" Title:` },
|
||||
{ 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: ` },
|
||||
]
|
||||
});
|
||||
|
||||
return completion.data.choices[0].message.content;
|
||||
return completion.data.choices[0].message.content.replace(/"/g, '');
|
||||
};
|
||||
|
||||
module.exports = titleConvo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue