Code Monkey home page Code Monkey logo

telegram-ai-bot's Introduction

Telegram AI Bot

A telegram bot to interact with AI. Currently only OpenAI API is supported

Features

  • Chat with ChatGPT
    • Switch between gpt-4 to gpt-3.5-turbo with /switch
  • View current configuration with /config
  • Generate images with DALL-E: /imagine
  • Transcribe audio and video with Whisper: Just send a voice message or a video file!
  • Voice chat with ChatGPT:
    • Send voice message.
    • Receive voice messages.
    • Use GoogleTTS for text to voice
  • Clear ChatGPT context history (to save tokens).
  • Reply to any message to use it as context for ChatGPT.
  • Persistent data with sqlite database.
  • Lightweight: few lines of code.

Hosting

Self hosting this chatbot is pretty easy. You just need to follow this steps:

  1. Get your OPENAI Token from here.
    • You will need to set a payment method.
  2. Generate a new bot:
    1. Start a new chat with @BotFather bot.
    2. Type /newbot command. Set a name and a username.
    3. Copy the Token that BotFather will give you.
  3. Get allowed users' IDs:
    1. Start a new chat with @RawDataBot.
    2. Send a message or forward a message from any desired user.
    3. Copy the message.from.id field value. Should be an ID like: 1234567890
  4. Setup the bot:
    1. Clone this repo.
    2. Rename the example.env file to .env.
    3. Edit the environment variables from the .env file:
      • Set your OPENAI_TOKEN.
      • Set your BOT_TOKEN.
      • Set your ALLOWED_USERS (; separated user ids). Set it to * to allow all users.
      • Set the CHAT_DEFAULT_SYSTEM_PROMPT for ChatGPT. This is always instructed to ChatGPT as the system.
      • Optional: Edit the CHAT_MAX_CONTEXT. This variable sets the number of messages that will be sent to ChatGPT API as context for the conversation.
      • ASR_TO_CHAT allows you to choose wether Whisper transcripts should be instructed to ChatGPT or not.
        • You can also configure this using /settings in chat.
      • ENABLE_TTS the TTS service will be provided by GoogleTTS, producing more natural voices. If disabled, it fallsback to local voice generation using Espeak.
      • VOICE_LANGUAGE country code for the default voice accent.
    4. Build and start the bot: docker compose up --build -d.
  5. Enjoy!

Usage

  • By simply sending normal chat messages, you will be interacting with ChatGPT.

    • The last 5 messages (from user and bot) are sent to ChatGPT API as context.
    • Use the command /clear to clear your context and start over a completely new chat.
  • By using the /imagine <prompt> command, you will be getting images generated by DALL-E.

    • Example: /imagine A cat with a red hat.
  • Sending a voice message to the bot, it will transcribe it to text using Whisper.

  • Using /settings you can configure a few settings.

  • Using /config you can view current configuration

  • Switch Between gpt3 and gpt3 with /switch

  • /usage command allows you to see your usage statistics.

telegram-ai-bot's People

Contributors

karendanielyan avatar vahedanielyan avatar

Watchers

 avatar

Forkers

karendanielyan

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.