Giter VIP home page Giter VIP logo

tao-multibot's Introduction

tao-multibot

LLM chat-bot infrastructure service featuring multiple bots instances with custom plugins (code/sql execution/document processing/etc.) and frontends (telegram, whatsapp, web).

Join Project's Telegram Group and share your ideas.

Getting started

python3 -m virtualenv .venv
source .venv/bin/activate

pip install -r requirements.txt

pytest

Then:

  • Create a telegram bot using @BotFather and get a token.
  • Set up an Openai account and get an API key.
  • Pull the repo

Create master.json:

{
    "infra": {
        "debug": false,
        "server": {
            "port": 8080
        },
        "postgres": {
            "enabled": false,
            "host": "localhost",
            "port": 5432,
            "user": "postgres",
            "password": "password",
            "schemas": "public"
        },
        "influxdb": {
            "enabled": false,
            "url": "http://localhost:8086",
            "org": "org",
            "bucket": "bucket",
            "token": "token123123token"
        }
    },
    "bots": {
        "<YOUR BOT USERNAME>": {
            "bot_id": "<YOUR BOT USERNAME>",
            "type": "tg_bot",
            "token": "<TELEGRAM BOT TOKEN>",
            "tao_bot": {
                "username": "<YOUR BOT USERNAME>",
                "chats": [],
                "admins": [
                    "<YOUR USERNAME>"
                ],
                "users": [],
                "bot_mention_names": [
                    "tao",
                    "тао"
                ],
                "control_chat_id": "-",
                "messages_per_completion": 20,
                "system_prompt": "./"
            },
            "gpt": {
                "url": "https://api.openai.com/v1/chat/completions",
                "type": "openai",
                "token": "<YOUR OPENAI TOKEN>",
                "model": "gpt-3.5",
                "temperature": 0,
                "max_tokens": 1000,
                "top_p": 1,
                "frequency_penalty": 0,
                "presence_penalty": 0
            }
        }
}

Note, here postgres and influxdb are disabled. Chat messages are saved in-memory. You can configure the services later.

All is done, fire up the platform:

python entrypoint.py
  • The app will use "./var" to store all files, including tmp files, logs, system prompts, etc.
  • To edit the system prompt refer to ./var/system_prompts/<bot name> (it is created automatically if not present).

Further steps

  • Set up ffmpeg for audio processing
  • Set up grafana + influxdb for metric collection
  • Set up flyway and postgres database to persist chat history
  • Create more bots by adding their respected confs into master.json
  • Set up a control chat (see "Authorisation" below)
  • Write your own plugin (can be remote)

Features

  • Authorisation: bots know their admins, users and chats. Bot do not respond to unauthorised updates. In addition there is a control chat. Admins and control chat can convey bot commands, hence changing bot's behaviour.
  • Plugins: bots can call functions (basically any internal and external API). Plugins have common interface and can be easily added to the bot. Example of plugins:
    • code execution
    • sql query any databases
    • web search
    • read pdf
    • generate images
    • send messages
    • transcribe audio
    • ... more to be invented
  • Voice recognition: bots use whisper to transcribe audio messages.
  • Vision: bots complete images as well as text
  • Observability: logs and metrics are written into influxdb that can be visualised in grafana
  • Chat persistance: chat history is saved in database
  • Extandable architecture: the platform allows using not only telegram bot frontends but also other types like:
    • whatsapp
    • programmable telegram accounts (telethon)
    • any web based chat (i.e. websocket client talking to your server)
    • etc.
  • System prompts: bots read system prompt in runtime from file. System prompt can be modified in runtime by the bot itself to persist relevant chat details and adjust bot's behaviour (dynamic sys prompts).
  • HTTP server: bots can be configured via HTTP API. This allows to control all bots from a single control panel.

Copilot notebook

Copilot notebook contains code that builds a systemp prompt out of all project files. Using this prompt the GPT can help you write code components and tests.

Logical diagram

doc/logical_diagram.png

tao-multibot's People

Contributors

jrojer avatar

Stargazers

nkudinov avatar  avatar Alexandr Ovsyannikov avatar  avatar  avatar  avatar

Watchers

 avatar  avatar Kostas Georgiou avatar

tao-multibot's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.