This is a simple Bot written in Python to bring ChatGPT directly into Python.
 
Go to file
Brayd ef4057742b
Add link to libolm repository
2023-01-15 22:39:16 +01:00
.gitignore Initial commit 2023-01-15 20:46:19 +01:00
LICENSE Initial commit 2023-01-15 20:46:19 +01:00
README.md Add link to libolm repository 2023-01-15 22:39:16 +01:00
main.py Initial commit 2023-01-15 20:46:19 +01:00
requirements.txt Initial commit 2023-01-15 20:46:19 +01:00

README.md

Matrix ChatGPT Bot

License LiberaPay
This is a simple Bot written in Python to bring ChatGPT directly into Python.

Disclaimer

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!

Setup

  1. Install Python3 and pip3
  2. 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!
  3. Install e2e support for matrix-nio by running:
pip3 install "matrix-nio[e2e]"
  1. Clone this repo using:
git clone https://code.braydmedia.de/brayd/matrix-chatgpt-bot.git
  1. Install requirements from requirements.txt using:
pip3 install -r requirements.txt
  1. Create a bot account on your Matrix server
  2. 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
  3. 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.
Also edit:

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:

python3 main.py

You can now start a chat with your bot and type your request like for e.g.:

! Tell me something about the Matrix Protocol