Reaction is a framework for fast and convenient DL models serving.

Quick start

import asyncio
from typing import List, Any
from reaction.rpc import RabbitRPC

class rpc(RabbitRPC):
    URL = 'amqp://user:[email protected]'

def sync_square(*values) -> List[float]:
    return [v ** 2 for v in values]

async def async_square(*values) -> List[float]:
    await asyncio.sleep(1)
    return [v ** 2 for v in values]

if __name__ == '__main__':
    loop = asyncio.get_event_loop()

import asyncio
from consumer import sync_square, async_square

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    x = loop.run_until_complete(, 3))
    y = loop.run_until_complete(, 5, 6))
    print(x)  # 4, 9
    print(y)  # 16, 25, 36


  • Register telegram bot, achieve token
  • cd example && TG_TOKEN="telegram bot token goes here" docker-compose up --force-recreate --build
  • RabbitMQ web ui:
    • user: admin
    • password: j8XfG9ZDT5ZZrWTzw62q
  • Docs (you can submit requests from web ui):
  • Redoc:
  • Telegram bot is ready to classify ants & bees, but you have to send files "as a photo"

Telegram bot quick howto

Install async telegram client first:

$ pip install aiotg

Then create your bot:

from consumer import async_square
from aiotg import Bot, Chat

bot = Bot(api_token='telegram bot token goes here')

async def start(chat: Chat, match):
    return chat.reply('Send me /square command with one float argument')

@bot.command(r"/square (.+)")
async def square_command(chat: Chat, match):
    val =
        val = float(val)
        square = await
        resp = f'Square for {val} is {square}'
        resp = 'Invalid number'
    return chat.reply(resp)