Giter Site home page Giter Site logo

telebot_lm's Introduction

Telegram LM chatbot

Chat with LM from Ollama using telegram chatbots.

Two telegram bots are used here:

  1. A management bot, which is running on cloudrun and which manages a VM
  2. A bot running on a VM, which runs the model

This is only so that we do not pay for our VM if we do not need it, but we can also choose to start / stop it via telegram whenever we like.

Setup

  1. Get three API tokens from the telegram BotFather (one for the management bot in cloudrun, one for the bot running on a VM and one for testing.)
  2. Make sure you write your own .env file and put it into the root of this directory
    # .env
    TOKEN=<TOKEN_LM>
    TOKEN_MANAGER=<TOKEN_MANAGER>
    TOKEN_TEST=<TOKEN_TEST>
    SERVICE_NAME=<SERVICE_NAME>
    PROJECT_ID=<PROJECT_ID>
    REGION=<REGION>
    ZONE=<ZONE>
    MACHINE_TYPE=<MACHINE_TYPE>
    PORT=<PORT>
    ADMIN_CHAT_ID=<ADMIN_CHAT_ID>
    

Development

  1. Install uv with curl -LsSf https://astral.sh/uv/0.2.11/install.sh | sh
  2. Make sure to have the correct python version available
  3. Create virtual environment with uv venv and sync dependencies with uv pip sync requirements/requirements.macos.dev.txt
  4. Run the polling bot using make run-polling

Deploy to CloudRun and GCE

Make sure the Google Cloud CLI is installed and that you have access to a google cloud project via the CLI.

NOTE: When deploying the app to cloudrun for the first time, the public URL is not available yet and the server fails. You can deploy the app without the lifespan hook, so that the url exists, and then redeploy again.

If you followed the setup above, you should be able to just run

make deploy

This will

  1. Build the docker file (optionally via make build)
  2. Push it to google artifact registry (optionally via make push)
  3. Deploy the image using google cloud run

In order to create a container VM to run the bot

make create_vm

When the machine is running, and you want to push updates to it, run

make create_vm

telebot_lm's People

Contributors

ademfr avatar

Watchers

 avatar

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.