This commit is contained in:
Ashley Graves 2024-10-08 11:17:38 +02:00
parent caf0339164
commit 88017c83cd
5 changed files with 60 additions and 7 deletions

View file

@ -31,7 +31,7 @@ module.exports = {
content: message.content
}
],
"model": "llama3-groq-70b-8192-tool-use-preview"
"model": interaction.defaultModel
});
await interaction.followUp(summary.choices[0].message.content);

View file

@ -1,4 +1,4 @@
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder } = require('discord.js');
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const data = new SlashCommandBuilder()
.setName('prompt')
@ -38,7 +38,7 @@ module.exports = {
await interaction.deferReply({ ephemeral: !(interaction.options.getBoolean("send") || true) });
const groq = interaction.client.groq;
const summary = await groq.chat.completions.create({
const response = (await groq.chat.completions.create({
messages: [{
role: "system",
content: interaction.client.prompts.query
@ -46,9 +46,20 @@ module.exports = {
role: "user",
content: interaction.options.getString("prompt")
}],
"model": interaction.options.getString("model") || "llama-3.1-70b-versatile"
});
"model": interaction.options.getString("model") || interaction.defaultModel
})).choices[0].message.content;
await interaction.followUp(summary.choices[0].message.content);
const embed = new EmbedBuilder()
.setTitle("Prompt")
.setFooter("")
.setFields([{
name: "Prompt",
value: interaction.options.getString("prompt")
}, {
name: "Response",
value: response.slice(0, (response.length > 1024 ? 1021 : 1024)) + (response.length > 1024 ? "..." : "")
}])
await interaction.followUp({ embeds: [embed] });
},
};

37
src/commands/ai/query.js Normal file
View file

@ -0,0 +1,37 @@
const { ContextMenuCommandBuilder, ApplicationCommandType, InteractionContextType, ApplicationIntegrationType } = require('discord.js');
const data = new ContextMenuCommandBuilder()
.setName('Query AI')
.setType(ApplicationCommandType.Message)
.setContexts([
InteractionContextType.Guild,
InteractionContextType.BotDM,
InteractionContextType.PrivateChannel
])
.setIntegrationTypes([
ApplicationIntegrationType.GuildInstall,
ApplicationIntegrationType.UserInstall
]);
module.exports = {
data,
async execute(interaction) {
await interaction.deferReply();
const groq = interaction.client.groq;
const message = interaction.targetMessage;
const summary = await groq.chat.completions.create({
messages: [{
role: "system",
content: interaction.client.prompts.query
}, {
role: "user",
content: message.content
}],
"model": interaction.defaultModel
});
await interaction.followUp(summary.choices[0].message.content);
},
};