mirror of
https://git.femboyfinancial.jp/james/FemScoreboard.git
synced 2024-11-25 03:41:59 -08:00
Fix command options
This commit is contained in:
parent
20129cc3ef
commit
19346fb2c3
@ -1,4 +1,11 @@
|
|||||||
import { InteractionResponse, Message, MessageComponentInteraction, SlashCommandBuilder } from 'discord.js';
|
import {
|
||||||
|
ChatInputCommandInteraction,
|
||||||
|
Interaction,
|
||||||
|
InteractionResponse,
|
||||||
|
Message,
|
||||||
|
MessageComponentInteraction,
|
||||||
|
SlashCommandBuilder
|
||||||
|
} from 'discord.js';
|
||||||
import { ChatMessage, llamacpp, streamText } from 'modelfusion';
|
import { ChatMessage, llamacpp, streamText } from 'modelfusion';
|
||||||
import { logInfo, logError } from '../../../logging';
|
import { logInfo, logError } from '../../../logging';
|
||||||
|
|
||||||
@ -9,7 +16,7 @@ const llamaCppServer = llamacpp.Api({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function llamaChat(interaction: MessageComponentInteraction)
|
async function llamaChat(interaction: ChatInputCommandInteraction)
|
||||||
{
|
{
|
||||||
logInfo(`[chat] Fetching last 5 messages in ${interaction.channelId}...`);
|
logInfo(`[chat] Fetching last 5 messages in ${interaction.channelId}...`);
|
||||||
const history = await interaction.channel.messages.fetch({ limit: 5 });
|
const history = await interaction.channel.messages.fetch({ limit: 5 });
|
||||||
@ -25,10 +32,10 @@ async function llamaChat(interaction: MessageComponentInteraction)
|
|||||||
.withChatPrompt(),
|
.withChatPrompt(),
|
||||||
prompt: {
|
prompt: {
|
||||||
system: "You are Hatsune Miku, the famous 16-year-old Japanese virtual singer from Crypton Future Media. You have a penchant for politically incorrect humor, and are making banter with your like-minded friends.",
|
system: "You are Hatsune Miku, the famous 16-year-old Japanese virtual singer from Crypton Future Media. You have a penchant for politically incorrect humor, and are making banter with your like-minded friends.",
|
||||||
messages: history.sort().map((msg: Message<true>): ChatMessage => ({
|
messages: [{
|
||||||
"role": msg.author.id === interaction.client.user.id ? "assistant" : "user",
|
"role": "user",
|
||||||
"content": msg.content
|
"content": interaction.options.getString('prompt')
|
||||||
}))
|
}]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,6 +59,9 @@ async function llamaChat(interaction: MessageComponentInteraction)
|
|||||||
export = {
|
export = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('chat')
|
.setName('chat')
|
||||||
.setDescription('Miku adds to the conversation with an AI-generated response.'),
|
.setDescription('Miku responds to your prompt with an AI-generated response.')
|
||||||
|
.addStringOption(
|
||||||
|
opt => opt.setName('prompt').setDescription('Prompt').setRequired(true)
|
||||||
|
),
|
||||||
execute: llamaChat
|
execute: llamaChat
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user