67 lines
2.4 KiB
TypeScript
Raw Normal View History

2024-03-31 21:36:09 +00:00
import {
ChatInputCommandInteraction,
SlashCommandBuilder
} from 'discord.js';
import { LLMConfig } from '../types';
2024-03-31 21:36:09 +00:00
import 'dotenv/config';
const config: LLMConfig = {
max_new_tokens: 128,
min_new_tokens: 1,
temperature: 0.9,
repetition_penalty: 1.5,
top_p: 0.9,
msg_context: 8
2024-03-31 21:36:09 +00:00
};
async function configCommand(interaction: ChatInputCommandInteraction)
{
if (interaction.user.id !== process.env.ADMIN) {
await interaction.reply("You are not authorized to change model settings");
return;
2024-03-31 21:36:09 +00:00
}
config.max_new_tokens = interaction.options.getInteger('max_new_tokens') ?? config.max_new_tokens;
config.min_new_tokens = interaction.options.getInteger('min_new_tokens') ?? config.min_new_tokens;
config.msg_context = interaction.options.getInteger('msg_context') ?? config.msg_context;
config.temperature = interaction.options.getNumber('temperature') ?? config.temperature;
config.top_p = interaction.options.getNumber('top_p') ?? config.top_p;
config.repetition_penalty = interaction.options.getNumber('repetition_penalty') ?? config.repetition_penalty;
2024-03-31 21:36:09 +00:00
await interaction.reply(`
\`\`\`
max_new_tokens = ${config.max_new_tokens}
min_new_tokens = ${config.min_new_tokens}
msg_context = ${config.msg_context}
temperature = ${config.temperature}
top_p = ${config.top_p}
repetition_penalty = ${config.repetition_penalty}
2024-03-31 21:36:09 +00:00
\`\`\`
`);
}
export = {
data: new SlashCommandBuilder()
.setName('llmconf')
.setDescription('Change model inference settings')
.addNumberOption(
opt => opt.setName('temperature').setDescription('Temperature (default: 0.9)')
)
2025-01-20 00:55:39 +00:00
.addNumberOption(
opt => opt.setName('repetition_penalty').setDescription('Repetition penalty (default: 1.5)')
)
.addNumberOption(
opt => opt.setName('top_p').setDescription('Cumulative probability of minimum token set to sample from (default: 0.9)')
)
2024-03-31 21:36:09 +00:00
.addIntegerOption(
opt => opt.setName('max_new_tokens').setDescription('Max. new tokens (default: 256)')
2024-03-31 21:36:09 +00:00
)
2025-01-29 02:08:02 +00:00
.addIntegerOption(
opt => opt.setName('min_new_tokens').setDescription('Min. new tokens (default: 1)')
)
2024-05-11 02:55:23 +00:00
.addIntegerOption(
opt => opt.setName('msg_context').setDescription('Num. messages in context (default: 8)')
2024-03-31 21:36:09 +00:00
),
execute: configCommand,
state: () => config,
2024-03-31 21:36:09 +00:00
};