AI Discord chat bot using OpenAI fine-tuning
pip install -r requirements.txt
pip install --upgrade openai
cp .env.example .env
- Navigate to https://discord.com/developers
- Add an application
- Click on the bot tab to add a bot to the application
- Click on OAuth2 -> URL Generator and select bot to generate a unique URL to add the bot to a server where you have admin privileges
DISCORD_TOKEN
: As specified above, the unique token for the Discord bot you've createdBOT_USERNAME
: Sets the command which the bot will respond to. For example ifBOT_USERNAME = test
, then the bot will respond to messages starting with!test
OPENAI_KEY
: OpenAI API KeyOPENAI_MODEL
: ID of the OpenAI model for the bot to use. This can be a standard model such ascurie
or a custom model you have fine-tuned based on chat history.
python bot.py
to start the bot
-
In a discord server with the bot, send the message
!history
to have the bot log the current channel's history, by user.- This will create
.jsonl
files for each user in the channel, which can then be input to OpenAI's fine-tuning feature.
- This will create
-
Select a user you'd like to model the AI on, and prepare the data:
openai tools fine_tunes.prepare_data -f channel_[channel_name]/[user].jsonl
- It is recommended to accept all of the edits that OpenAI suggests - these will be saved in a new file. Finally, submit the prepared data to OpenAI:
openai api fine_tunes.create -t "channel_[channel_name]/[user]_prepared.jsonl" --batch_size 1
- Once the model is created, update
.env
to use this model, and interact with the bot using![BOT_USER]
. For example, if your bot is based on the Discord usertest
, then the bot will respond to messages starting with!test
Contact tv#3636 on Discord with any questions