(interaction, client, commands, commandType, options)
| 53 | ) |
| 54 | ), |
| 55 | async execute(interaction, client, commands, commandType, options) { |
| 56 | var message; |
| 57 | var model; |
| 58 | var preset; |
| 59 | await commandType.load(interaction); |
| 60 | if (!interaction.options) { |
| 61 | message = options.message; |
| 62 | model = options.model; |
| 63 | preset = options.preset; |
| 64 | } else { |
| 65 | message = interaction.options.getString("message"); |
| 66 | if ( |
| 67 | message.includes("@everyone") || |
| 68 | message.includes("<@") || |
| 69 | message.includes("@here") |
| 70 | ) { |
| 71 | return; |
| 72 | } |
| 73 | model = interaction.options.getString("model"); |
| 74 | preset = interaction.options.getString("preset"); |
| 75 | } |
| 76 | if (!model) model = "OA_SFT_Llama_30Bq"; |
| 77 | if (!preset) preset = "k50"; |
| 78 | // sleep for 30s |
| 79 | |
| 80 | const OA = await createInferenceClient( |
| 81 | interaction.user.username, |
| 82 | interaction.user.id |
| 83 | ); |
| 84 | |
| 85 | try { |
| 86 | let chat = await redis.get(`chat_${interaction.user.id}`); |
| 87 | let chatId = chat ? chat.split("_")[0] : null; |
| 88 | let parentId = chat ? chat.split("_")[1] : null; |
| 89 | if (!chatId) { |
| 90 | let chat = await OA.create_chat(); |
| 91 | chatId = chat.id; |
| 92 | } |
| 93 | let prompter_message = await OA.post_prompter_message({ |
| 94 | chat_id: chatId, |
| 95 | content: message, |
| 96 | parent_id: parentId, |
| 97 | }); |
| 98 | |
| 99 | let assistant_message = await OA.post_assistant_message({ |
| 100 | chat_id: chatId, |
| 101 | model_config_name: model, |
| 102 | parent_id: prompter_message.id, |
| 103 | sampling_parameters: presets[preset], |
| 104 | }); |
| 105 | await redis.set( |
| 106 | `chat_${interaction.user.id}`, |
| 107 | `${chatId}_${assistant_message.id}` |
| 108 | ); |
| 109 | |
| 110 | const row = new ActionRowBuilder().addComponents( |
| 111 | new ButtonBuilder() |
| 112 | .setStyle(ButtonStyle.Secondary) |
nothing calls this directly
no test coverage detected