This repository is a fork/clone of the discord-gpt3-chatbot by [Jman4190], which was originally licensed under the Apache License 2.0.
During Moravian's CS220A (DevOps) course, we collaborated on creating a Discord bot, harnessing the Discord and OpenAI APIs. This integration allows the Discord bot to engage users in natural language conversations, mimicking the conversational style and intelligence of ChatGPT 3.5. Our deployment strategy involved containerizing the bot on a Linux EC2 instance and implementing Redis databse for efficient storage of user input data.
Screen.Recording.2024-04-30.at.8.11.29.AM.mov
The following sections describe how to setup the system so it will run locally (i.e. on your laptop). For deployment on an EC2 instance, see the sections in the Running with Docker in EC2 Instance
To run this application on your local device, follow the steps below:
Ensure you have the necessary dependencies installed. This will vary based on the programming language and libraries used in the project.
git clone <repository_url>
cd <project_directory>
Create a file .env
that contains the hostname and port number for Redis. We will run Redis on our laptop (localhost
) using the standard Redis port (6379). Replace <Discord_Token>
with your Discord Token and <OPENAI_KEY>
with your OPENAI key:
DISCORD_TOKEN = '<Discord_Token>'
OPENAI_KEY = "<OPENAI_KEY?"
REDIS_HOST=localhost
REDIS_PORT=6379
Do 'bash localdeploy.sh'. This script should handle the setup, create a virtual environment, install dependencies, run redis as a background process, and start the bot application.
To run this application using Docker, follow the steps below:
ssh -i ~/.ssh/labsuser.pem ec2-user@ip-address
Use the scp command to from a separate terminal (NOT THE ONE THAT YOU SSH'D INTO) to copy your local files up to your EC2 instance
scp -i /path/to/your/key.pem /path/to/local/file.txt ec2-user@your-ec2-ip-address:/path/to/remote/directory
cd <project_directory>
Do 'bash dockerdeploy.sh'. This script should handle the setup, install docker on the EC2 instance, install dependencies, run redis as a background process, run docker as a system process and compose bot application