Skip to main content

OpenAI GPT, driven by Telegram

Project description

TeLLMgramBot

The basic goal of this project is to create a bridge between a Telegram Bot and a Large Langage Model (LLM), like ChatGPT.

Telegram Bot + LLM Encapsulation

The telegram interface handles special commands, and even some basic "chatty" prompts and reponses that don't require a LLM to interpret, like saying "Hello". The more dynamic conversation gets handed off to the LLM to manage prompts and responses, and Telegram acts as the interaction broker. The bot can also handle URLs. If you want the bot to interpret a URL, pass it a url [in brackets] and mention what you want the bot to do with it. (e.g. - What do you think of this article? [https://some_site/article])

Why Telegram?

Using Telegram as the interface not only solves "exposing" the interface, but gives you boadloads of interactivity over a standard Command Line interface, or trying to create a website with input boxes and submit buttons to try to handle everything:

  1. Telegram already lets you paste in verbose, multiline messages.
  2. Telegram already lets you paste in pictures, videos, links, etc.
  3. Telegram already lets you react with emojis, stickers, etc.

API Keys

To function, the bot requires three API keys:

  • OpenAI - To drive the actual GPT AI.
  • Telegram Bot - Created after chatting with BotFather.
  • VirusTotal - To perform safety checks on URLs.

Bot Setup

  1. To initialize the bot, install via PIP (pip install TeLLMgramBot) and then import into your project.
  2. Instantiate the bot by passing in various configuration pieces needed. Use OpenAI Playground to test more your prompt.
    telegram_bot = TeLLMgramBot.TelegramBot(
        bot_username   = <Bot username like 'friendly_bot'>,
        bot_nickname   = <Bot nickname like 'Botty'>,
        bot_initials   = <Bot initials like 'FB'>,
        bot_owner      = <Bot owner's username>,
        bot_owner_uid  = <Bot owner's UID set by BotFather>,
        chatmodel      = <ChatGPT model type like 'gpt-3.5-turbo'>,
        persona_name   = <Bot name like 'Friendly Bot'>
        persona_prompt = <Prompt like 'prompts/url_analysis.prmpt' on bot's characteristics>
    )
    
  3. Run by calling:
    telegram_bot.start_polling()
    
  4. Once you see Polling..., the bot is online. Switch to Telegram and initiate a conversation with your bot there by passing the /start command.
    • NOTE: The bot will only respond to the /start command coming from the bot_owner_uid of the owner specified.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TeLLMgramBot-1.0.3.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TeLLMgramBot-1.0.3-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file TeLLMgramBot-1.0.3.tar.gz.

File metadata

  • Download URL: TeLLMgramBot-1.0.3.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for TeLLMgramBot-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9865bd98e32cf31514675385f2feceb09ad6b4e5ef3d8a7660d1be2209e612d6
MD5 f7373705498e63aa9d2918ee598dcb61
BLAKE2b-256 31f5791180bfe7807251f38bd340f42a1a1bbc81d6a71b44f30d26bfec9b4711

See more details on using hashes here.

File details

Details for the file TeLLMgramBot-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: TeLLMgramBot-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for TeLLMgramBot-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 959fc12ed1ace656cc044316dd4a93048d32c1e66a09af93eee058ec5e25669f
MD5 6f7ccb11d78cc07f66986a5d02bc0f87
BLAKE2b-256 2e2c2285876d57c05c94d8704535817d508c7c860255e26e14d438c3ba7c1c6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page