A simple Discord bot showing how to use GPT-4's Vision to understand videos
This repository contains a simple Discord bot demonstrating the use of GPT-4 Vision (GPT-4V) with the OpenAI API. It can process text, images, and videos (passing 25% of the frames from a video).
gpt4vbotexample.mp4
- Handles image attachments in formats including PNG, JPG, JPEG, and WEBP.
- Processes video attachments, extracting frames from MP4, MOV, and WEBM files.
- Will never max out model token limit in a discord conversation, as messages are handled seperately from one another.
This repository is a proof of concept and is not intended to be used as-is for any deployment. I would highly recommend modifying this code to bring more functionality out of any Discord Bot you're planning to make with this.
The following libraries and environments are required:
Follow these steps to set up the bot:
- Clone or download the source code from the repository.
- Install the required Python packages:
pip install -r requirements.txt
- Set up your
env
file in the project's root directory with your Discord and OpenAI API keys:DISCORD_TOKEN=<your_discord_token> OPENAI_API_KEY=<your_openai_api_key>
To use the bot:
-
Run the bot script from your command line:
python gpt-4v-bot.py
-
In your Discord server, interact with the bot by sending text, images, or videos.
Contributions for improvements or new features are welcome. Please use the standard workflow of fork, branch, and pull request for contributions.
This project is licensed under the MIT License. See the LICENSE file for details.
- This bot was inspired by the GPT-4 Developer Livestream Discord Bot example
- Special thanks for the resources like the OpenAI Cookbook, particularly the example on GPT with Vision for Video Understanding written by Kai Chen, which guided the development of video processing features in this bot.