add model to session

This commit is contained in:
Christopher Cookman 2023-07-13 11:10:24 -06:00
parent 7d9754d6f8
commit 191e9bf04e
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -178,11 +178,13 @@ client.on('messageCreate', async (message) => {
if (!sessions[message.channelId]) { if (!sessions[message.channelId]) {
if (message.channel.nsfw) { if (message.channel.nsfw) {
sessions[message.channelId] = { sessions[message.channelId] = {
model: config.discord.authorized_channels[message.channelId] || config.discord.authorized_channels[message.channel.parentId],
messages: [basePrompt, nsfwPrompt], messages: [basePrompt, nsfwPrompt],
started: new Date(), started: new Date(),
} }
} else { } else {
sessions[message.channelId] = { sessions[message.channelId] = {
model: config.discord.authorized_channels[message.channelId] || config.discord.authorized_channels[message.channel.parentId],
messages: [basePrompt], messages: [basePrompt],
started: new Date(), started: new Date(),
}; };
@ -217,9 +219,8 @@ client.on('messageCreate', async (message) => {
"role": "user" "role": "user"
}); });
// Send the message to OpenAI // Send the message to OpenAI
var model = config.discord.authorized_channels[message.channelId] || config.discord.authorized_channels[message.channel.parentId];
await openai.createChatCompletion({ await openai.createChatCompletion({
model: model, model: sessions[message.channelId].model,
messages: sessions[message.channelId].messages messages: sessions[message.channelId].messages
}).then((data) => { }).then((data) => {
output = data.data.choices[0].message; output = data.data.choices[0].message;