James Shiffer
8ef7a03895
changed some defaults; added and then decided to drop repetition penalty related hyperparameters; fixed prompt formatting
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import {
|
|
ChatInputCommandInteraction,
|
|
SlashCommandBuilder
|
|
} from 'discord.js';
|
|
import 'dotenv/config';
|
|
import { MikuAIProvider } from '../../provider/mikuai';
|
|
import { HuggingfaceProvider } from '../../provider/huggingface';
|
|
|
|
const PROVIDERS = {
|
|
mikuai: new MikuAIProvider(),
|
|
huggingface: new HuggingfaceProvider()
|
|
};
|
|
let provider = PROVIDERS.huggingface;
|
|
|
|
async function providerCommand(interaction: ChatInputCommandInteraction)
|
|
{
|
|
if (interaction.user.id !== process.env.ADMIN) {
|
|
await interaction.reply("You are not authorized to change model settings");
|
|
return;
|
|
}
|
|
|
|
const chosenProvider = interaction.options.getString('name', true);
|
|
if (Object.keys(PROVIDERS).includes(chosenProvider)) {
|
|
provider = PROVIDERS[chosenProvider];
|
|
}
|
|
await interaction.reply(`Using provider ${provider.name()}.`);
|
|
}
|
|
|
|
export = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('provider')
|
|
.setDescription('Change model backend')
|
|
.addStringOption(
|
|
opt => opt.setName('name')
|
|
.setDescription('Name of model backend')
|
|
.setRequired(true)
|
|
.addChoices(
|
|
...Object.keys(PROVIDERS)
|
|
.map(key => ({
|
|
name: PROVIDERS[key].name(),
|
|
value: key
|
|
}))
|
|
)
|
|
),
|
|
execute: providerCommand,
|
|
state: () => provider
|
|
};
|