This Discord bot integrates with the GPT Trainer API to provide interactive conversations and generate responses based on user prompts with an uploaded knowledge base and capabilities for a multi-agent system. It allows users to chat with a virtual assistant powered by the GPT Trainer API.
- Interact with the bot using the
/prof
command followed by a prompt (this can easily be changed in the code, by replacing wherever it says "prof" with whatever you want) - The bot generates a response using the GPT Trainer API based on the provided prompt and your uploaded sources.
- Supports handling long responses by splitting them into multiple messages
- Implements basic rate limiting to avoid excessive API requests
-
Python 3.x:
- Download: Ensure you have the latest version from the official Python website: https://www.python.org/downloads/
- Installation: Follow the instructions for your operating system.
-
Discord Bot Token:
- Discord Developer Portal: Visit Dev Portal
- Create an Application: Click "New Application" and give your bot a name.
- Bot Creation: Navigate to the "Bot" tab and click "Add Bot".
- Token: Under the bot's profile, you'll see a "Token" section. Click "Copy" to obtain your token. Keep this token secure!
-
GPT Trainer API Token and Chatbot UUID:
- GPT Trainer Website: Visit https://gpt-trainer.com/
- Account Creation: Create an account.
- Create a Chatbot: Follow the GPT Trainer platform's instructions to create a new chatbot project.
- API Token and UUID: Within your chatbot project settings, you should find your API token and the chatbot's unique UUID.
Additional Notes
- GPT Trainer Documentation: Refer to the official documentation on the GPT Trainer website for the most up-to-date guidance on setting up your chatbot and obtaining the prerequisites.
- Code Examples: GPT Trainer likely provides code examples or a library to ease the interaction between your Discord bot and their service.
- Go to the Discord Developer Portal: https://discord.com/developers/applications
- Click on "New Application" and give your bot a name.
- In the left sidebar, click on "Bot" and then click on "Add Bot".
- Customize your bot's name and profile picture if desired.
- Under the "Token" section, click on "Copy" to copy your bot token. Keep this token secure and do not share it with anyone.
- In the left sidebar, click on "OAuth2" and then click on "URL Generator".
- Under "Scopes", select "bot".
- Under "Bot Permissions", select the permissions your bot requires (e.g., "Send Messages", "Read Message History").
- Copy the generated OAuth2 URL and paste it into your web browser.
- Select the Discord server you want to add the bot to and click on "Authorize".
-
Install Git on your computer if you haven't already. You can download it from the official website: https://git-scm.com/downloads
-
Open a terminal or command prompt and navigate to the directory where you want to store the project.
-
Run the following command to clone the repository:
git clone https://github.com/your-username/your-repo.git
Replace
your-username
with your GitHub username andyour-repo
with the name of the repository.
-
Install Visual Studio Code (VS Code) on your computer. You can download it from the official website: https://code.visualstudio.com/download
-
Open VS Code and go to File -> Open Folder. Navigate to the directory where you cloned the repository and select it.
-
Open a terminal within VS Code by going to Terminal -> New Terminal.
-
Run the following command to create a virtual environment:
python -m venv venv
- For Windows:
venv\Scripts\activate
- For macOS and Linux:
source venv/bin/activate
- Install the required dependencies by running the following command:
pip install -r requirements.txt
-
Create a new file named
.env
in the project directory. -
Open the
.env
file and add the following lines:DISCORD_TOKEN=your-discord-bot-token GPT_TRAINER_TOKEN=your-gpt-trainer-api-token CHATBOT_UUID=your-gpt-trainer-chatbot-uuid
Replace
your-discord-bot-token
,your-gpt-trainer-api-token
, andyour-gpt-trainer-chatbot-uuid
with your actual tokens and UUID.The UUID can be found in your chatbot's dashboard in the top left under your Chatbots name.
-
In the VS Code terminal, run the following command to start the bot:
python main.py
-
The bot should now be running and connected to your Discord server.
If you want to host the bot continuously without running it on your local machine, you can use platforms like Replit or Railway.
-
Sign up for a free account on Replit.(Note you will need to purchase an account to keep it continuosly running.
-
Click on the "+" button to create a new repl.
-
Select "Python" as the language and give your repl a name.
-
In the Replit editor, upload the files from your local project directory (
main.py
,discord_api.py
). -
Open the "Secrets" tab (bottom left in the list) and add in all of your keys (Bot token, GPT Trainer API, UUID for your chatbot)
-
Click on the "Run" button to start the bot.
-
Keep the Replit tab open to keep the bot running continuously.
-
Sign up for a free account on Railway.
-
Create a new project and select "Deploy from GitHub".
-
Connect your GitHub account and select the repository containing your bot code.
-
Configure the environment variables (Discord bot token, GPT Trainer API token, and chatbot UUID) in the Railway dashboard.
-
Click on "Deploy" to deploy your bot.
-
Railway will provide you with a URL where your bot is hosted and running continuously.
-
Invite the bot to your Discord server using the OAuth2 URL generated in the Discord Developer Portal.
-
Use the
/prof
command followed by a prompt to interact with the bot. For example:/prof What is the meaning of life?
-
The bot will generate a response based on the provided prompt and send it back to the Discord channel.
- Add ability to find and summarize shared links.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.