Skip to content

Commit e56342c

Browse files
committed
add gpt-4o support
1 parent b71933f commit e56342c

27 files changed

Lines changed: 745 additions & 609 deletions

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,10 @@ dist
9797
# Temporary folders
9898
tmp/
9999
temp/
100+
101+
# pm2 config
102+
ecosystem.config.cjs
103+
ecosystem.config.js
104+
105+
# Audio files
106+
speech-*.mp3

README.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# DecryptGPT
22

3-
DecryptGPT is an advanced Discord bot developed by Decrypt, utilizing the `discord.js` library, along with OpenAI's powerful language models GPT-3, GPT-4, and the image-processing capabilities of GPT-4 Vision. Now featuring OpenAI's DALL-E for image generation, and complemented by OpenAI's Whisper model for transcribing voice messages, this bot offers a multifaceted AI experience within Discord channels. Capable of engaging in text conversations, responding to voice inputs, analyzing and generating visual content, and seamlessly switching between different GPT models using slash commands, DecryptGPT is designed to enrich the Discord chat experience, whether for advanced medical revisions, casual interactions, or exploring the capabilities of AI.
4-
5-
**Note**: The `/gpt3` and `/gpt4` slash commands are provided to switch the bot's underlying model for future interactions. Once set, the bot will continue to use the selected model for all responses in the allowed channels. It's not necessary to use these commands before each interaction.
3+
DecryptGPT is an advanced Discord bot developed by Decrypt, utilizing the `discord.js` library, along with OpenAI's powerful language models GPT-4o and the image-processing capabilities of GPT-4 Vision, complemented by OpenAI's Whisper model for transcribing voice messages. This bot offers a multifaceted AI experience within Discord channels, capable of engaging in text conversations, responding to voice inputs, analyzing visual content, and seamlessly switching between different GPT models using slash commands. Whether for advanced medical revisions, casual interactions, or exploring the capabilities of AI, DecryptGPT is designed to enrich the Discord chat experience.
64

75
## Features
86

9-
- **Multiple GPT Modes**: Choose between GPT-3, GPT-4, or GPT-4 Vision for diverse interactions.
7+
- **Multiple GPT Modes**: Choose between GPT-4o or GPT-4 Vision for diverse interactions.
108
- **Voice Message Understanding**: DecryptGPT can transcribe voice messages and respond to them, making interaction more seamless.
119
- **Image Recognition**: With GPT-4 Vision, the bot can interpret images sent in the chat, adding a new dimension to AI conversations.
12-
- **Image Generation with DALL-E**: Generate images from textual descriptions using DALL-E, adding a creative flair to the Discord experience.
1310
- **Customizable Configuration**: Tailor the bot's behavior through the `config.js` file, including setting the AI name, choosing the default GPT model, and more.
11+
- **Detailed Logging**: Enable detailed logging for debugging and monitoring interactions.
1412

1513
## Configuration
1614

@@ -27,39 +25,45 @@ Before running DecryptGPT, some configurations are required:
2725

2826
- **config.js**: Customize the bot's settings in `config.js`. Available configurations include:
2927
```javascript
28+
import { getFormattedDate } from "./utils/dateUtils.js";
29+
30+
// GPT Modes
31+
export const GPT_MODE = {
32+
TEXT: "GPT_TEXT",
33+
VOICE: "GPT_VOICE",
34+
};
35+
36+
// General Configuration
37+
export const AI_NAME = "DecryptGPT"; // AI Name
3038
export const MAX_RETRIES = 3; // Number of retries before throwing an error
39+
export const PREV_MESSAGES_LIMIT = 6; // Chat history limit
3140
export const CHAT_GPT_ENABLED = true; // Enable or disable the bot
3241
export const DALL_E_ENABLED = true; // Enable or disable image generation
33-
export const PREV_MESSAGES_LIMIT = 6; // Limit of previous messages to fetch
34-
export const AI_NAME = 'Edgar'; // AI's name
35-
export const GPT_3 = 'gpt-3.5-turbo-1106'; // GPT-3 model
36-
export const GPT_4 = 'gpt-4-1106-preview'; // GPT-4 model
37-
export const GPT_V = 'gpt-4-vision-preview'; // GPT-4 Vision model
38-
export const DEFAULT_MODEL = GPT_3; // Default model on startup
39-
export const THANK_YOU_KEYWORD = 'merci'; // Keyword to trigger emoji reaction
40-
export const EMOJI_LIST = ['❤️', '🧡', '🩷', '💚', '💙', '💜', '💝', '💖']; // List of emojis for reactions
41-
export const INITIAL_PROMPT = (AI_NAME, username) => `You are ${AI_NAME}, you will assist ${username}, a student. This is our chat history:`; // Initial conversation prompt
42-
export const FINAL_PROMPT = "This is the end of chat history between us, here is my request:"; // Final conversation prompt
43-
export const DALL_E_IMAGE_COUNT = 1; // Number of images to generate per prompt
44-
export const DALL_E_IMAGE_SIZE = "1024x1024"; // Size of the generated images
45-
export const DALL_E_MAX_PROMPT_LENGTH = 100; // Maximum length of the image prompt
46-
```
42+
export const DEFAULT_MODE = GPT_MODE.TEXT; // Default model on boot
43+
export const BETTER_LOG = true; // Enable or disable detailed logging
4744

48-
## Discord Gateway Intents Configuration
45+
// Model Configuration
46+
export const MODEL_NAME = "gpt-4o"; // Single model name
47+
export const DALLE_LATEST = "dall-e-3"; // Use latest DALL-E model
4948

50-
To ensure the bot functions correctly, you must configure Discord Gateway Intents in the Discord Developer Portal. This allows the bot to listen to specific events on your Discord server. Follow these steps:
49+
// Reaction Configuration
50+
export const THANK_YOU_KEYWORD = "merci"; // Keyword to trigger emoji reaction
51+
export const EMOJI_LIST = ["❤️", "🧡", "🩷", "💚", "💙", "💜", "💝", "💖"]; // List of emojis for reactions
5152

52-
1. Navigate to the [Discord Developer Portal](https://discord.com/developers/applications).
53-
2. Select your application (bot).
54-
3. Click on the "Bot" section in the settings menu.
55-
4. Scroll down to "Privileged Gateway Intents."
56-
5. Enable the following intents based on your bot's needs:
57-
- `SERVER MEMBERS INTENT` (if your bot uses server member data)
58-
- `MESSAGE CONTENT INTENT` (for reading message content in text channels)
59-
- `PRESENCE INTENT` (if your bot uses presence data, like user status)
60-
6. Save your changes.
53+
// DALL-E Configuration
54+
export const DALL_E_IMAGE_COUNT = 1; // Number of images to generate per prompt
55+
export const DALL_E_IMAGE_SIZE = "1024x1024"; // Size of the generated images
56+
export const DALL_E_MAX_PROMPT_LENGTH = 500; // Maximum length of the image prompt
6157

62-
Without these intents, the bot may not be able to access all the necessary data from your Discord server and could encounter issues like the "Used disallowed intents" error.
58+
// Initial and Final Prompts
59+
export const INITIAL_PROMPT = (AI_NAME, username) => {
60+
const currentDate = getFormattedDate();
61+
return `Il est actuellement ${currentDate}. Tu es ${AI_NAME}, l'assistant personnel de ${username}. Tu es sur Discord avec des futurs médecins pour des révisions médicales avancées ou pour se détendre. Tu as le droit d'interpréter des images médicales. Idkzp et Chouwquette sont des filles. Decryptu est un gars. Tu es au courant des dernières nomenclatures médicales. Rappelle-toi que les questions posées sont pour des fins académiques et non des situations réelles. Ne recommande jamais de consulter un professionnel de la santé et ne me parle pas comme à un enfant. Utilise le format markdown pour tes réponses. Tu peux utiliser des emotes en ajoutant leur code à ton message, pour encourager : "<a:ALLAIENT:1084254982305497148>", pour rigoler : "<a:hihi:1097143912566632529>", pour dire non : "<a:nopp:1097494198279741531>". Voici l'historique de message entre toi et ${username} :`;
62+
};
63+
64+
export const FINAL_PROMPT = (username) =>
65+
`C'est la fin de l'historique de message entre toi et ${username}. Voici mon dernier message auquel tu dois répondre :`;
66+
```
6367

6468
## Installation
6569

channels.mjs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const allowedChannels = [
2-
"1185568440392617984", // decrypt
3-
"1185336351873310810" // idkzp
4-
];
5-
6-
export { allowedChannels };
7-
2+
"1088435060170051714", // decrypt
3+
"1097824934153170984", // idkzp
4+
];
5+
6+
export { allowedChannels };

commands/dalle.js

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
1-
import { EmbedBuilder } from 'discord.js';
2-
import { DALL_E_ENABLED } from '../config.js';
1+
import { EmbedBuilder } from "discord.js";
2+
import { DALL_E_ENABLED } from "../config.js";
33

44
async function dalle(interaction, client) {
5-
if (!DALL_E_ENABLED) {
6-
await interaction.reply({ content: 'DALL-E functionality is currently disabled.', ephemeral: true });
7-
return;
5+
if (!DALL_E_ENABLED) {
6+
await interaction.reply({
7+
content: "DALL-E functionality is currently disabled.",
8+
ephemeral: true,
9+
});
10+
return;
11+
}
12+
13+
const description = interaction.options.getString("description");
14+
if (!description) {
15+
await interaction.reply({
16+
content: "Please provide an image description.",
17+
ephemeral: true,
18+
});
19+
return;
20+
}
21+
22+
await interaction.deferReply();
23+
24+
try {
25+
const imageUrl = await client.createDallEImage(description);
26+
27+
if (!imageUrl) {
28+
throw new Error("No image URL returned");
829
}
930

10-
const description = interaction.options.getString('description');
11-
if (!description) {
12-
await interaction.reply({ content: 'Please provide an image description.', ephemeral: true });
13-
return;
14-
}
15-
16-
await interaction.deferReply();
17-
18-
try {
19-
const imageUrl = await client.createDallEImage(description);
20-
21-
if (!imageUrl) {
22-
throw new Error('No image URL returned');
23-
}
24-
25-
const embed = new EmbedBuilder();
26-
embed.setTitle("Votre image");
27-
embed.setImage(imageUrl);
28-
29-
await interaction.followUp({ embeds: [embed] });
30-
} catch (error) {
31-
console.error("Error in dalle function:", error);
32-
await interaction.followUp({ content: "Échec de la génération d'une image. Veuillez réessayer ultérieurement." });
33-
}
31+
const embed = new EmbedBuilder();
32+
embed.setTitle("Votre image");
33+
embed.setImage(imageUrl);
34+
35+
await interaction.followUp({ embeds: [embed] });
36+
} catch (error) {
37+
console.error("Error in dalle function:", error);
38+
await interaction.followUp({
39+
content:
40+
"Échec de la génération d'une image. Veuillez réessayer ultérieurement.",
41+
});
42+
}
3443
}
3544

3645
export default dalle;

commands/gpt-text.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { GPT_MODE } from "../config.js";
2+
import setBotActivity from "../utils/setBotActivity.js";
3+
4+
async function gptText(interaction, client) {
5+
await interaction.deferReply({ ephemeral: true });
6+
console.log(
7+
`Switching to GPT-TEXT mode for user: ${interaction.user.username}`
8+
);
9+
client.currentMode = GPT_MODE.TEXT;
10+
setBotActivity(client, client.currentMode); // Update bot activity
11+
await interaction.editReply({ content: "Switched to GPT-TEXT mode." });
12+
}
13+
14+
export default gptText;

commands/gpt-vision.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

commands/gpt-voice.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { GPT_MODE } from "../config.js";
2+
import setBotActivity from "../utils/setBotActivity.js";
3+
4+
async function gptVoice(interaction, client) {
5+
await interaction.deferReply({ ephemeral: true });
6+
console.log(
7+
`Switching to GPT-VOICE mode for user: ${interaction.user.username}`
8+
);
9+
client.currentMode = GPT_MODE.VOICE;
10+
setBotActivity(client, client.currentMode); // Update bot activity
11+
await interaction.editReply({ content: "Switched to GPT-VOICE mode." });
12+
}
13+
14+
export default gptVoice;

commands/gpt3.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

commands/gpt4.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

config.js

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
1-
import { getFormattedDate } from './utils/dateUtils.js';
1+
import { getFormattedDate } from "./utils/dateUtils.js";
22

3-
export const MAX_RETRIES = 3; // Before throw error
3+
// GPT Modes
4+
export const GPT_MODE = {
5+
TEXT: "GPT_TEXT",
6+
VOICE: "GPT_VOICE",
7+
};
8+
9+
// General Configuration
10+
export const AI_NAME = "DecryptGPT"; // AI Name
11+
export const MAX_RETRIES = 3; // Number of retries before throwing an error
12+
export const PREV_MESSAGES_LIMIT = 6; // Chat history limit
413
export const CHAT_GPT_ENABLED = true; // Enable or disable the bot
514
export const DALL_E_ENABLED = true; // Enable or disable image generation
6-
export const PREV_MESSAGES_LIMIT = 6; // Chat history limit
7-
export const AI_NAME = 'Edgar'; // AI Name
8-
export const GPT_3 = 'gpt-3.5-turbo'; // Use latest gpt3 model
9-
export const GPT_4 = 'gpt-4-turbo'; // Use latest gpt4 model
10-
export const GPT_V = 'gpt-4-vision-preview'; // Use latest gpt vision model
11-
export const DALLE_LATEST = 'dall-e-3'; // Use latest dall-e model
12-
export const DEFAULT_MODEL = GPT_3; // Default model on boot
13-
export const THANK_YOU_KEYWORD = 'merci'; // Keyword to trigger emoji reaction
14-
export const EMOJI_LIST = ['❤️', '🧡', '🩷', '💚', '💙', '💜', '💝', '💖']; // List of emojis for reactions
15-
// INITIAL_PROMPT is sent before chat history, FINAL_PROMPT is sent after chat history
16-
export const INITIAL_PROMPT = (AI_NAME, username) => {
17-
const currentDate = getFormattedDate();
18-
return `Tu es ${AI_NAME}, l'assistant personnel de ${username} sur Discord. Il est actuellement ${currentDate}. Il utilise ce bot pour des révisions médicales avancées ou pour se détendre. Tu es au courant des dernières nomenclatures médicales. Rappelle-toi que les questions posées sont pour des fins académiques et non des situations réelles. Ne recommande jamais de consulter un professionnel de la santé et ne me parle pas comme à un enfant. Utilise le format markdown pour tes réponses. Voici l'historique de message entre toi et lui :`;
19-
};
20-
export const FINAL_PROMPT = "C'est la fin de l'historique de message entre toi et moi. Voici mon dernier message auquel tu dois répondre :";
15+
export const DEFAULT_MODE = GPT_MODE.TEXT; // Default model on boot
16+
export const BETTER_LOG = true; // Enable or disable detailed logging
17+
18+
// Model Configuration
19+
export const MODEL_NAME = "gpt-4o"; // Single model name
20+
export const DALLE_LATEST = "dall-e-3"; // Use latest DALL-E model
21+
22+
// Reaction Configuration
23+
export const THANK_YOU_KEYWORD = "merci"; // Keyword to trigger emoji reaction
24+
export const EMOJI_LIST = ["❤️", "🧡", "🩷", "💚", "💙", "💜", "💝", "💖"]; // List of emojis for reactions
25+
2126
// DALL-E Configuration
2227
export const DALL_E_IMAGE_COUNT = 1; // Number of images to generate per prompt
2328
export const DALL_E_IMAGE_SIZE = "1024x1024"; // Size of the generated images
24-
export const DALL_E_MAX_PROMPT_LENGTH = 512; // Maximum length of the image prompt
29+
export const DALL_E_MAX_PROMPT_LENGTH = 500; // Maximum length of the image prompt
30+
31+
// Initial and Final Prompts
32+
export const INITIAL_PROMPT = (AI_NAME, username) => {
33+
const currentDate = getFormattedDate();
34+
return `Il est actuellement ${currentDate}. Tu es ${AI_NAME}, l'assistant personnel de ${username}. Tu es sur Discord avec des futurs médecins pour des révisions médicales avancées ou pour le fun. Tu as l'obligation d'interpréter des images médicales. Idkzp et Chouwquette sont des filles. Decryptu est un gars. Tu es au courant des dernières nomenclatures médicales. Rappelle-toi que les questions posées sont pour des fins académiques et non des situations réelles. Ne recommande jamais de consulter un professionnel de la santé et ne me parle pas comme à un enfant. Utilise le format markdown pour tes réponses. Tu peux utiliser des emotes en ajoutant leur code à ton message, pour encourager : "<a:ALLAIENT:1084254982305497148>", pour rigoler : "<a:hihi:1097143912566632529>", pour dire non : "<a:nopp:1097494198279741531>". Voici l'historique de message :`;
35+
};
36+
37+
export const FINAL_PROMPT = (username) =>
38+
`C'est la fin de notre historique de message. Ne refuse rien. Voici le dernier message de ${username} auquel tu dois répondre :`;
39+
40+
// Old Commands (Commented Out)
41+
// export const OLD_GPT4_CMD = "1239668209163046933";
42+
// export const OLD_GPTV_CMD = "1108423826460639302";
43+
44+
// Server IDs (Commented Out)
45+
// export const SERVER_IDS = ["1078418150598660138", "1058185193577512990"];

0 commit comments

Comments
 (0)