Skip to content

Commit

Permalink
chore(ask.builder.ts): increase max length of prompt option to 1000 c…
Browse files Browse the repository at this point in the history
…haracters

feat(ask.builder.ts): add model option with choices for GPT 3.5 Turbo and GPT 4
fix(ask.cmd.ts): check if user is premium before using GPT 4 model, display premium message if not
feat(premium.config.ts): add advantage of using GPT 4 model for premium users in multiple languages
feat(command.config.ts): add message for non-premium users to get premium for using GPT 4 model
  • Loading branch information
Steellgold committed Jul 26, 2023
1 parent 74898e1 commit 65f611b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/commands/ask/ask.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ export const slashCommand: SlashCommandDefition = new SlashCommandBuilder()
.setDescription(ask.options.prompt.description["en-US"])
.setDescriptionLocalizations(ask.options.prompt.description)
.setRequired(true)
.setMaxLength(500))
.setMaxLength(1000))
.addStringOption(new SlashCommandStringOption()
.setName("model")
.setDescription(ask.options.model.description["en-US"])
.setDescriptionLocalizations(ask.options.model.description)
.setRequired(false)
.addChoices(
{ name: "GPT 3.5 Turbo", value: "gpt-3.5-turbo"},

Check failure on line 25 in src/commands/ask/ask.builder.ts

View workflow job for this annotation

GitHub Actions / ESLint

A space is required before '}'
{ name: "GPT 4", value: "gpt-4"}

Check failure on line 26 in src/commands/ask/ask.builder.ts

View workflow job for this annotation

GitHub Actions / ESLint

A space is required before '}'
))
.addStringOption(new SlashCommandStringOption()
.setName("context")
.setDescription(ask.options.context.description["en-US"])
Expand Down
11 changes: 9 additions & 2 deletions src/commands/ask/ask.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { limitString, userWithId } from "$core/utils/function";
import { QuestionIncludeAll, getQuestion, newQuestion, updateQuestion } from "$core/utils/data/question";
import { getPrompt } from "@bottlycorp/prompts";
import { simpleButton, simpleEmbed } from "$core/utils/embed";
import { buttonsBuilder, favoriteButton, qrCodeButton, regenerateButton, revealButton, usageButton } from "$core/utils/config/buttons";
import { buttonsBuilder, favoriteButton, premiumButton, qrCodeButton, regenerateButton, revealButton, usageButton } from "$core/utils/config/buttons";
import { updateUser } from "$core/utils/data/user";
import { DayJS } from "$core/utils/day-js";
import { supabase } from "$core/utils/supabase";
Expand All @@ -28,10 +28,17 @@ import QRCode from "qrcode";
export const execute: CommandExecute = async(command, user) => {
const web = command.options.getBoolean("web", false) ?? false;
const context = command.options.getString("context", false) ?? "";
const model = command.options.getString("model", false) ?? "gpt-3.5-turbo";

const channel = command.channel;
const askedAt = DayJS().unix();

if (model !== "gpt-3.5-turbo" && user.isPremium === false) {
const premiumEmbed = simpleEmbed(translate(command.locale, global.exec.orGetPremiumGPT4), "premium");
command.editReply({ embeds: [premiumEmbed], components: [{ type: 1, components: [premiumButton(command)]}] });

Check failure on line 38 in src/commands/ask/ask.cmd.ts

View workflow job for this annotation

GitHub Actions / ESLint

A space is required before '}'
return;
}

const handleNotInTextChannel = (): void => {
command.editReply(translate(command.locale, global.exec.notInATextChannel));
colors.error(userWithId(command.user) + " tried to ask a question while not being in a text channel (thread or text channel)");
Expand Down Expand Up @@ -86,7 +93,7 @@ export const execute: CommandExecute = async(command, user) => {
const response = await openai.createChatCompletion({
messages,
max_tokens: user.isPremium ? 3750 : 2500,
model: "gpt-3.5-turbo",
model: model || "gpt-3.5-turbo",
user: `${command.user.id}-${command.guild?.id}`
});

Expand Down
14 changes: 14 additions & 0 deletions src/commands/ask/ask.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ export const ask = {
de: "Die Frage, die an die künstliche Intelligenz gerichtet werden soll"
}
},
model: {
name: {
"en-US": "model"
},
description: {
"en-US": "The model to use to answer the question",
fr: "Le modèle à utiliser pour répondre à la question",
"pt-BR": "O modelo a ser usado para responder a pergunta",
ru: "Модель, которую нужно использовать для ответа на вопрос",
uk: "Модель, яку потрібно використовувати для відповіді на питання",
"es-ES": "El modelo a utilizar para responder a la pregunta",
de: "Das Modell, das zur Beantwortung der Frage verwendet werden soll"
}
},
context: {
name: {
"en-US": "context"
Expand Down
7 changes: 7 additions & 0 deletions src/commands/premium/premium.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const premium = {
"en-US": [
"{emojiPremium} You are not a premium user.",
"\n**What are the advantages ?**",
"• Use **GPT 4** and **GPT 4 (32k)** models instead of **GPT 3.5 Turbo** (You can still use GPT 3.5 Turbo)",
"• You have 50 uses per day",
"• You have priority access to support",
"• You have 50% more writing power on your questions and discussions",
Expand All @@ -125,6 +126,7 @@ export const premium = {
fr: [
"{emojiPremium} Vous n'êtes pas un utilisateur premium.",
"\n**Quels sont les avantages ?**",
"• Utilisez les modèles **GPT 4** et **GPT 4 (32k)** au lieu de **GPT 3.5 Turbo** (Vous pouvez toujours utiliser GPT 3.5 Turbo)",
"• Vous avez 50 utilisations par jour",
"• Vous avez un accès prioritaire au support",
"• Vous avez 50% de puissance d'écriture en plus sur vos questions et discussions",
Expand All @@ -140,6 +142,7 @@ export const premium = {
"pt-BR": [
"{emojiPremium} Você não é um usuário premium.",
"\n**Quais são as vantagens ?**",
"• Use os modelos **GPT 4** e **GPT 4 (32k)** em vez de **GPT 3.5 Turbo** (Você ainda pode usar o GPT 3.5 Turbo)",
"• Você tem 50 usos por dia",
"• Você tem acesso prioritário ao suporte",
"• Você tem 50% a mais de poder de escrita em suas perguntas e discussões",
Expand All @@ -155,6 +158,7 @@ export const premium = {
ru: [
"{emojiPremium} Вы не являетесь премиум-пользователем.",
"\n**Каковы преимущества ?**",
"• Используйте модели **GPT 4** и **GPT 4 (32k)** вместо **GPT 3.5 Turbo** (Вы все еще можете использовать GPT 3.5 Turbo)",
"• У вас есть 50 использований в день",
"• У вас есть приоритетный доступ к поддержке",
"• У вас на 50% больше мощности записи в ваших вопросах и обсуждениях",
Expand All @@ -170,6 +174,7 @@ export const premium = {
uk: [
"{emojiPremium} Ви не є преміум-користувачем.",
"\n**Які переваги ?**",
"• Використовуйте моделі **GPT 4** і **GPT 4 (32k)** замість **GPT 3.5 Turbo** (Ви все ще можете використовувати GPT 3.5 Turbo)",
"• У вас є 50 використань на день",
"• У вас є пріоритетний доступ до підтримки",
"• У вас на 50% більше потужності запису в ваших питаннях та обговореннях",
Expand All @@ -185,6 +190,7 @@ export const premium = {
"es-ES": [
"{emojiPremium} No eres un usuario premium.",
"\n**¿Cuáles son las ventajas ?**",
"• Use los modelos **GPT 4** y **GPT 4 (32k)** en lugar de **GPT 3.5 Turbo** (Todavía puede usar GPT 3.5 Turbo)",
"• Tienes 50 usos por día",
"• Tiene acceso prioritario al soporte",
"• Tiene un 50% más de potencia de escritura en sus preguntas y discusiones",
Expand All @@ -200,6 +206,7 @@ export const premium = {
de: [
"{emojiPremium} Sie sind kein Premium-Benutzer.",
"\n**Was sind die Vorteile ?**",
"• Verwenden Sie die Modelle **GPT 4** und **GPT 4 (32k)** anstelle von **GPT 3.5 Turbo** (Sie können immer noch GPT 3.5 Turbo verwenden)",
"• Sie haben 50 Anwendungen pro Tag",
"• Sie haben Prioritätszugang zum Support",
"• Sie haben 50% mehr Schreibkraft bei Ihren Fragen und Diskussionen",
Expand Down
11 changes: 10 additions & 1 deletion src/utils/config/message/command/command.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,23 @@ export const global = {
].join(" ")
},
orGetPremium: {
fr: ":sparkles: Vous pouvez aussi devenir premium pour 5.00$/mois et augmenter votre nombre d'utilisation à 50/jour",
"en-US": ":sparkles: You can also become premium for $5.00/month and increase your number of uses to 50/day",
fr: ":sparkles: Vous pouvez aussi devenir premium pour 5.00$/mois et augmenter votre nombre d'utilisation à 50/jour",
"pt-BR": ":sparkles: Você também pode se tornar premium por $5.00/mês e aumentar seu número de usos para 50/dia",
ru: ":sparkles: Вы также можете стать премиумом за 5,00$/месяц и увеличить количество использований до 50/день",
uk: ":sparkles: Ви також можете стати преміумом за 5,00$/місяць і збільшити кількість використань до 50/день",
"es-ES": ":sparkles: También puedes convertirte en premium por $5.00/mes y aumentar tu número de usos a 50/día",
de: ":sparkles: Sie können auch für 5,00 $ / Monat Premium werden und Ihre Anzahl der Verwendungen auf 50 / Tag erhöhen"
},
orGetPremiumGPT4: {
"en-US": ":sparkles: The use of GPT 4 is reserved for premium members, you can become premium for $5.00/month",
fr: ":sparkles: L'utilisation de GPT 4 est réservée aux membres premium, vous pouvez devenir premium pour 5.00$/mois",
"pt-BR": ":sparkles: O uso do GPT 4 é reservado para membros premium, você pode se tornar premium por $5.00/mês",
ru: ":sparkles: Использование GPT 4 зарезервировано для премиум-пользователей, вы можете стать премиумом за 5,00$/месяц",
uk: ":sparkles: Використання GPT 4 зарезервовано для преміум-користувачів, ви можете стати преміумом за 5,00$/місяць",
"es-ES": ":sparkles: El uso de GPT 4 está reservado para miembros premium, puede convertirse en premium por $5.00/mes",
de: ":sparkles: Die Verwendung von GPT 4 ist Premium-Mitgliedern vorbehalten. Sie können für 5,00 $ / Monat Premium werden"
},
error: {
"en-US": "An error occurred while executing the command: **{error}**",
fr: "Une erreur s'est produite lors de l'exécution de la commande: **{error}**",
Expand Down

0 comments on commit 65f611b

Please sign in to comment.