Matrix ChatGPT Bot
This bot is not suited for the use in big channels or by many users. Your OpenAI API Key will get rate limited, if many requests are made to the bot in a short period of time. See this bot primarly for something for personal use or in small groups with your friends or family. I'll maybe add the option to whitelist specific users who are allowed to use the bot via a config or similar in the future.
Attention: If you push your changes to this repository DO NOT push your login credentials or API Keys. If you accidentally do, change them immediately!
- Install Python3 and pip3
- Follow the README.md of the libolm repository to install libolm 3 or newer. You will need this for the bot to work in addition to the requirements.txt!
- Install e2e support for matrix-nio by running:
pip3 install "matrix-nio[e2e]"
- Clone this repo using:
git clone https://code.braydmedia.de/brayd/matrix-chatgpt-bot.git
- Install requirements from requirements.txt using:
pip3 install -r requirements.txt
- Create a bot account on your Matrix server
- Logout of your Matrix client with the bot account (if you haven't created it via a Synapse command or the AdminAPI), so the session will be cancelled
- Open main.py with a text editor (for e.g. nano, vim or neovim) and edit:
creds = botlib.Creds("https://matrix.example.com", "bot_user_name", "password")
with your Matrix Homeserver URL, your bot username (without the @) and your bot accounts password.
openai.api_key = "OPENAI TOKEN HERE"
with your OpenAI Token which you can get in your account settings directly from OpenAI.
9. Save the edited main.py file
10. Start the bot using:
You can now start a chat with your bot and type your request like for e.g.:
! Tell me something about the Matrix Protocol