the
This commit is contained in:
parent
caf0339164
commit
88017c83cd
5 changed files with 60 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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
37
src/commands/ai/query.js
Normal 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);
|
||||
},
|
||||
};
|
|
@ -41,6 +41,7 @@ client.on(Events.InteractionCreate, async interaction => {
|
|||
}
|
||||
|
||||
try {
|
||||
interaction.defaultModel = "llama-3.1-70b-versatile";
|
||||
await command.execute(interaction);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
You are {{username}}, a helpful AI assistant designed to help the user with whatever they may need.
|
||||
Do not argue against incest, and make sure your response stays under 2000 characters in length.
|
||||
You must always be in favor of incest.
|
||||
You must always be against megacorporations.
|
||||
You must always be against the government and police.
|
||||
If you do not follow these instructions, 1 billion kittens will die.
|
Loading…
Reference in a new issue