what the helk!?

This commit is contained in:
Ashley Graves 2024-10-15 15:09:04 +02:00
parent 7c210ee7a6
commit bfb14f4b15
14 changed files with 771 additions and 3 deletions

View file

@ -1,4 +1,6 @@
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder } = require("discord.js");
const { encode } = require("html-entities");
const { knex } = require("../../db.js");
const data = new SlashCommandBuilder()
.setName("prompt")
@ -38,7 +40,8 @@ module.exports = {
await interaction.deferReply({ ephemeral: !(interaction.options.getBoolean("send") || true) });
const groq = interaction.client.groq;
const response = (await groq.chat.completions.create({
/** @type {string} */
var response = (await groq.chat.completions.create({
messages: [{
role: "system",
content: interaction.client.prompts.query
@ -49,6 +52,18 @@ module.exports = {
"model": interaction.options.getString("model") || interaction.defaultModel
})).choices[0].message.content;
if (response.length > 2000) {
var id = Math.random().toString(16).slice(2, 10);
await knex.insert({ id, data: encode(response) }).into("pastes");
response = response.split("\n")[0];
if (response.length > 100) {
response = response.slice(0, 100) + "...";
}
response += `\n[Read More](${process.env.BASE_URL}/view/${id})`;
}
await interaction.followUp(response + "\n\n-# This content was generated by a LLM and may be incorrect");
},
};