A powerful Discord bot that integrates OpenAI's latest models (GPT-4, GPT-4 Vision, DALL-E 3) to provide advanced chat capabilities and AI-powered features in your Discord server. The bot supports:
- Text conversations with GPT-4 and other OpenAI models
- Image analysis and generation using GPT-4 Vision and DALL-E 3
- Document processing (PDF, TXT) with built-in memory
- RAG (Retrieval-Augmented Generation) capabilities using VectorDB
- Persistent conversation history
- Custom prompt management
- Multiple AI Models: Support for various OpenAI models including gpt-4-1106-preview and gpt-4-vision-preview
- Document Processing: Upload and analyze PDF and TXT files
- Long-term Memory: Store and search through documents using VectorDB
- Image Capabilities: Analyze images with GPT-4 Vision and generate images with DALL-E 3
- Context Management: Maintain conversation context within sessions
- Custom Commands: Accessible via the '!' prefix
All commands start with the prefix !
. Here are some key commands:
help
- Show this messageremind me
- Set a reminder that will ping you in a specified amount of time- Format:
[remind me], [description], [numerical value], [time unit (s,m,h)]
- Format:
draw
- Generate images using DALL-E 3- Format:
[draw]; [prompt]
- Format:
chroma status
- Get the status of the Chroma Vector DB for ChatGPT memoryupload
- Upload a text document (.pdf or .txt) to be stored into the Vector DBquery
- Query documents in the Vector DB to talk with ChatGPT- Format:
[query] [prompt]
- Format:
_attachTextFile
- Command for GPT interpreter- Format:
_attachTextFile [commentary] [code]
- Use
<CODESTART>
<CODEEND>
for code segments - Use
<COMMENTSTART>
<COMMENTEND>
for commentary
- Format:
help (h)
- Display this messageconvo len (cl)
- Show current GPT context lengthreset thread (rt)
- Reset GPT context lengthshow thread (st)
- Show the entire current conversation contextgptsettings
- Show the current GPT settingsgptset
- Modify GPT settings- Format:
gptset [setting_name] [new_value]
- Format:
current prompt (cp)
- Get the current prompt namechange prompt (chp)
- Change to a new prompt- Format:
change prompt, [new prompt name]
- Format:
list prompts (lp)
- List available promptslist models (lm)
- List available GPT modelsmodify prompts
- Modify the prompts for GPTsave thread
- Save the current GPT thread to a fileshow old threads
- Show saved threadsload thread
- Load a GPT thread from file- Format:
load thread, [unique id]
- Format:
delete thread
- Delete a GPT thread- Format:
delete thread, [unique id]
- Format:
current model (cm)
- Show the current GPT modelswap
- Switch between models (gpt-4-0125-preview, gpt-4-vision-preview)
The easiest way to get started.
- Ensure variables are in your
.env
file. - Source your env file to load the variables in the current shell's env.
- Run
docker compose up
. This will run the application and keep the shell attached to the container's logs. If you want to run this detached, rundocker compose up -d
.
To stop the running containerized application, run docker compose down
.
Note the default docker compose configuration creates a persistent volume that will store your RAG files, custom prompts,
and any saved threads to disk.
If you want to remove the persisted data in the named volume defined in the docker-compose.yml
run docker compose down -v
.
-
Prerequisites:
- Get Discord Bot Token
- New Application for Discord Bot on Discord Developer Portal
- Invited your new bot into your discord server
- Help: video
- Get OpenAI API Key
- You'll need to create an account with OpenAI and create an API key, put that in the
.env
file.
- You'll need to create an account with OpenAI and create an API key, put that in the
- If you want to pass PDFs into the bot, you will need to have the
tesseract
binary in your path. Instructions for installing it can be found here.
- Get Discord Bot Token
-
Clone/fork this repo
-
cd
into the repo -
Python Environment Setup:
conda create -n my_discord_bot python=3.12 conda activate my_discord_bot pip install -r requirements.txt
Yes use this specific python version.
5. Create a .env
file and put all your API keys and other info in there
6. Run with python ./main.py
.
To run unit tests
python -m unittest discover -v -s ./tests