A simple GPT discord bot with implementations in node.js and python.
-
You should have a discord server set up with a bot created. You can learn how to do this in the first half of this tutorial.
-
An embeddings vector DB that has been created with Supabase. You'll need to use the PGVector extension and create a function which allows you to run a k-nearest-neighbors search on the embeddings DB. There's a great tutorial on getting this set up by the Supabase team. You can find it here.
-
You'll need an OpenAI API Key. You can get this from OpenAI directly.
-
Create a new .env file based on
.env.template
and add your Supabase URL & key, Discord token, and OpenAI API key there. -
Finally, you should have up to date versions of node and python on your machine.
Once you have your embeddings DB and discord bot set up in the Discord developer portal, you'll want to choose either the python or node implementation.
- Run
npm install
to install deps - Be sure to change the
companyName
andbotName
variables to reflect your company's name and the name of your bot. ThebotName
MUST match the name of the discord bot you created in the Discord developer dashboard. - Start the server by running node node/index.js
- Tag your bot in a new discord message with @myBotName and ask it a question. If everything works correctly, your bot should create a new thread with the chatGPT response there.
- Use
pip install
to install deps:
pip install -U discord.py
pip install langchain
pip install openai
pip install supabase
- Be sure to change the
company_name
anddiscord_bot_name
variables to reflect your company's name and the name of your bot. Thediscord_bot_name
MUST match the name of the discord bot you created in the Discord developer dashboard. - Start the server by running python python/index.js
- Tag your bot in a new discord message with @myBotName and ask it a question. If everything works correctly, your bot should create a new thread with the chatGPT response there.