Matrix bot that generates messages based off of messages of other users using a neural network.
Go to file
2022-08-16 02:36:47 -04:00
.gitignore ignore AI related files 2022-08-15 23:38:00 -04:00
example.config.json configuration file 2022-08-16 00:39:40 -04:00
index.js js exec py and return str 2022-08-16 02:36:47 -04:00
LICENSE Initial commit 2022-08-15 00:50:58 -04:00
package.json dependencies 2022-08-15 17:17:45 -04:00
pnpm-lock.yaml dependencies 2022-08-15 17:17:45 -04:00
README.md export chat history using element 2022-08-16 01:27:53 -04:00
textgen.py js exec py and return str 2022-08-16 02:36:47 -04:00

text-gen-bot

Matrix bot that generates messages based off of messages of other users using a neural network.

Usage

First install the needed libraries. Then copy example.config.json and rename it config.json. Replace the items in angled brackets with their respective values of the bot account (e.g. replace <DOMAIN.TLD> with the homeserver url like https://matrix.org or https://matrix.arrayinamatrix.xyz). An explanation of each configurable string is located in configurations section of this document. To obtain the token of an account follow the instructions here.

Once the config file has been populated with valid data, execute the index.js file (Warning: executing for the first time will be slow.).

$ node index.js
...
<some warnings show up, ignore them>
...
Client has started!
...

If you do not want to wait until the bot creates its own dataset from new messages, you can export chat history easily using Element. In this case, you will need to manually remove the time stamps from the text file.

Setup

The project is split into 2 parts index.js and textgen.py. The index.js file contains the code that interacts with the user on Matrix and sends text generated by the textgen.py file.

Install JavaSript SDK:

> pnpm add matrix-bot-sdk

Install Python module:

> pip3 install aitextgen

Configurations

Before a bot can be used the fields in the config.json file must be populated with valid information. Values in angled brackets (stared below) must be supplied before usage.

 homeserver*        URL of the bot's homeserver.

 token*             Account token used to sign in the bot.

 user*              Account's User ID.

 file              Path of file used for training the AI (.txt file only).

 prefix            Bot listens to commands that start with this prefix.

 frequency         How often the bot sends a message (keep low to prevent spam).

 size              Bot starts generating messages when the number of lines in the training file is equal to this. The greater the size, the longer bot waits before messaging but might increase message quality.