Skip to content

a-abukar/AI-Discord-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT Discord bot

Introduction

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.

Getting started

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.

Pre-requisites

# Clone the repository
git clone https://github.com/<username>/<repository>.git

# Install the dependencies
pip install -r requirements.txt

Arguments

  • 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

Running the bot

Locally with Python

python run.py

Locally with Python - in a virtual environment

  1. Install virtualenv using python3 -m pip install --user virtualenv
  2. Create the virtual environment using python3 -m venv myenv in your Python working directory
  3. Activate the virtual environment using source myenv/bin/activate
  4. Run which python - you will see the /path/to/your/myenv

In a container

  1. Build the docker image using this command:
docker build -t chatgpt-docker-bot .
  1. Run the container in the backgroun
docker run -d chatgpt-docker-bot .

Using the bot

Once the bot is running, you can use it in any Discord channel by mentioning it and asking a question.

To prompt the ai-bot:

  • Begin your prompt with /ai
  • For example "/ai Write me a terraform resource block and use backticks to make a code block

Additional Resources

Contribution

  • 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

TODO

  • Reactivate OpenAI account PAYG

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published