Allow configuring what model is to be used for each channel/category

This commit is contained in:
Christopher Cookman 2023-07-13 11:05:27 -06:00
parent 19ce0b0c0a
commit 7d9754d6f8
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
9 changed files with 5 additions and 4 deletions

0
.gitignore vendored Normal file → Executable file
View file

0
basePrompt.txt Normal file → Executable file
View file

0
commands.json Normal file → Executable file
View file

0
config.json.default Normal file → Executable file
View file

9
index.js Normal file → Executable file
View file

@ -21,7 +21,7 @@ const colors = require("colors");
// Create a new Discord client // Create a new Discord client
const client = new Discord.Client({ const client = new Discord.Client({
intents: ["MessageContent", "GuildMessages", "Guilds", "DirectMessages"] intents: ["MessageContent", "GuildMessages", "Guilds", "DirectMessages", "GuildMessages"]
}); });
@ -88,7 +88,7 @@ client.on("ready", async () => {
client.on('interactionCreate', async (interaction) => { client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
if (interaction.guild !== null) { if (interaction.guild !== null) {
if ((!config.discord.authorized_channels.includes(interaction.channelId) && !config.discord.authorized_channels.includes(interaction.channel.parentId))) return interaction.reply({ if ((!config.discord.authorized_channels[message.channelId] && !config.discord.authorized_channels[message.channel.parentId])) return interaction.reply({
ephemeral: true, ephemeral: true,
content: lang.noauth content: lang.noauth
}); // Only allow messages in the authorized channels }); // Only allow messages in the authorized channels
@ -171,7 +171,7 @@ client.on('interactionCreate', async (interaction) => {
client.on('messageCreate', async (message) => { client.on('messageCreate', async (message) => {
if (message.author.bot) return; if (message.author.bot) return;
if (message.guild !== null) { if (message.guild !== null) {
if ((!config.discord.authorized_channels.includes(message.channelId) && !config.discord.authorized_channels.includes(message.channel.parentId))) return; // Only allow messages in the authorized channels if ((!config.discord.authorized_channels[message.channelId] && !config.discord.authorized_channels[message.channel.parentId])) return; // Only allow messages in the authorized channels
} }
if (message.content.startsWith("!!")) return; // So you can chat without the bot replying if (message.content.startsWith("!!")) return; // So you can chat without the bot replying
// If the session doesn't exist, create it // If the session doesn't exist, create it
@ -217,8 +217,9 @@ 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: "gpt-3.5-turbo", model: 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;

0
lang.json Normal file → Executable file
View file

0
nsfwPrompt.txt Normal file → Executable file
View file

0
package-lock.json generated Normal file → Executable file
View file

0
package.json Normal file → Executable file
View file