Welcome to this Discord bot that uses chatGPT! This bot is designed to respond to members queries in a Discord channel with natural language responses generated by the ChatGPT model.
The bot:
- Is built using the Discord.py library and the OpenAI GPT-3 API,
- Allows for easy integration with Discord and access to the powerful language generation capabilities of ChatGPT.
To get started, you'll need to create a new bot on Discord and get its API token. You can do this by following the instructions here
Once you have your API token, open the .env file, and add it to the DISCORD_KEY environment variable.
# Clone the repository
git clone https://github.com/<username>/<repository>.git
# Install the dependencies
pip install -r requirements.txt
- The arguments for chatGPT are built-in within the code
- Go to line 14 on file
app/openai_api/connect_openai.py
- You can change the model and max_tokens to better fit your Discord channel
- Get your openAI API Key from this link
- Add your API key and your Discord bot token to your .env file containing your environment variables
python run.py
- Install virtualenv using
python3 -m pip install --user virtualenv
- Create the virtual environment using
python3 -m venv myenv
in your Python working directory - Activate the virtual environment using
source myenv/bin/activate
- Run
which python
- you will see the/path/to/your/myenv
- Build the docker image using this command:
docker build -t chatgpt-docker-bot .
- Run the container in the backgroun
docker run -d chatgpt-docker-bot .
Once the bot is running, you can use it in any Discord channel by mentioning it and asking a question.
- Begin your prompt with
/ai
- For example "/ai Write me a terraform resource block and use backticks to make a code block
- This project is open source, so contributions are welcome
- If you would like to contribute, raise a PR, and myself and the team will have a look as soon as possible
- Reactivate OpenAI account PAYG