skygpu / skynet

Decentralized compute layer
https://explorer.skygpu.net/v2/explore
GNU Affero General Public License v3.0
3 stars 0 forks source link

Add Matrix bot support #32

Open iamzoltan opened 10 months ago

iamzoltan commented 10 months ago

We already have a discord and telegram bot, so this should not be too bad, but I think it would be cool to have an additional matrix bot for skynet

guilledk commented 9 months ago

Outlining what we need for matrix bot, using telegram bot as example:

Help text showing all the funtionality:

test art bot v0.1a12

commands work on a user per user basis!
config is individual to each user!

/txt2img TEXT - request an image based on a prompt
/img2img <attach_image> TEXT - request an image base on an image and a prompt

/redo - redo last command (only works for txt2img for now!)

/help step - get info on step config option
/help guidance - get info on guidance config option

/cool - list of cool words to use
/stats - user statistics
/donate - see donation info

/config algo NAME - select AI to use one of:
/config model NAME - select AI to use one of:

midj
stable
stable2
stablexl0.9
hdanime
waifu
ghibli
van-gogh
pokemon
ink
robot
stablexl

/config step NUMBER - set amount of iterations
/config seed [auto|NUMBER] - set the seed, deterministic results!
/config width NUMBER - set horizontal size in pixels
/config height NUMBER - set vertical size in pixels
/config upscaler [off/x4] - enable/disable x4 size upscaler
/config guidance NUMBER - prompt text importance
/config strength NUMBER - importance of the input image for img2img

Functions & database schema for client side bots: https://github.com/skygpu/skynet/blob/master/skynet/db/functions.py

Generic work request function (given a request & message / chat id return image): https://github.com/skygpu/skynet/blob/8a415b450f0be57fdf633ccca6c109dc638f933e/skynet/frontend/telegram/__init__.py#L112

Set config telegram handler: https://github.com/skygpu/skynet/blob/8a415b450f0be57fdf633ccca6c109dc638f933e/skynet/frontend/telegram/handlers.py#L61

guilledk commented 9 months ago

Also some values are taken from: https://github.com/skygpu/skynet/blob/8a415b450f0be57fdf633ccca6c109dc638f933e/skynet/constants.py#L35

guilledk commented 9 months ago

Ah! and forgot to point out the cmd line entry points:

for telegram bot: https://github.com/skygpu/skynet/blob/8a415b450f0be57fdf633ccca6c109dc638f933e/skynet/cli.py#L366

for database: https://github.com/skygpu/skynet/blob/8a415b450f0be57fdf633ccca6c109dc638f933e/skynet/cli.py#L318

guilledk commented 9 months ago

Transaction example: https://testnet.skygpu.net/v2/explore/transaction/599cfbb5259fa7c080d2c9908687be30c69c52809021cada3fa566bd626cf68a

sc

goodboy commented 9 months ago

Prolly maubot is the fastest to get going since it's a pretty decent ecosystem as far as i gather. Specifically the python apis are similar using decorator style:

from maubot import Plugin, MessageEvent
from maubot.handlers import command

class ExampleBot(Plugin):
  @command.new()
  async def hello_world(self, evt: MessageEvent) -> None:
    await evt.reply("Hello, World!")

Resources:


Tasks for PoC

I'd like to move this to the body description likely so that this comment doesn't get too long 😂

The solution is standalone mode: a separate entrypoint that runs a single maubot plugin with a predefined Matrix account.

Additionally, standalone mode supports using appservice transactions to receive events instead of /sync, which is often useful for huge production instances with lots of traffic.

goodboy commented 9 months ago

Follow up quick sniff for GH-only themed matrix bots in python (since other deps are in that):

https://github.com/topics/matrix-bot?l=python https://github.com/vranki/hemppa https://github.com/valcanobacon/BoostBots https://github.com/coffeebank/coffee-maubot https://github.com/Forden/aiomatrix https://github.com/uniberry-info/lokibot https://github.com/dominiwe/matrix-ai-assistant

cryptoapebot commented 9 months ago

Not sure any of those support encrypted rooms--not that it has to, but I know encrypted room support is supposed to be easier in Python vs. Java. FWIW I tried using a laimon proxy but never got it to work (not E2E & also the E2E docs are ambiguous).

goodboy commented 9 months ago

Not sure any of those support encrypted rooms--not that it has to,

I mean I already linked to this:

decisions about whether or not to do encryptiion

in my previous comment


in case it wasn't clear bc nooone is clicking links -> encryption is 💯 supported

guilledk commented 9 months ago

Ok, so idea would be: