/Telegrambot-with-GPT4free

telegram bot with gpt

Primary LanguagePython

Telegrambot-with-GPT4free

🤖 A Telegram bot powered by ChatGPT using the Aiogram API.

ℹ️ Note: The Hugging Face token is only required for image captioning.

Image generation is currentky not working as imaginepy API is down. I am looking for an aternative. Open to suggestions.

✨ Features:

Installation Steps

Linux

Download or clone this repository
Go to the directory

git clone https://github.com/noes14155/Telegrambot-with-GPT4free
cd Telegrambot-with-GPT4free

Copy example.env file to .env

cp example.env .env

Change environment variables in .env file Environment Variables

nano .env

Create virtual environment for this project/directory

python3 -m venv venv
source venv/bin/activate

Install the requirements

apt install -y flac ffmpeg tesseract-ocr
wget https://github.com/tesseract-ocr/tessdata_fast/raw/main/script/Devanagari.traineddata -P /usr/share/tesseract-ocr/4.00/tessdata/script/
EXPORT TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata

pip install -r requirements.txt

Run the bot

python main.py

Windows

  1. Download or clone this repository:
git clone https://github.com/noes14155/Telegrambot-with-GPT4free
cd Telegrambot-with-GPT4free
  1. Copy the example.env file to .env

  2. Change the environment variables in the .env file using a text editor of your choice.

  3. Create a virtual environment for this project/directory:

python -m venv venv
venv\Scripts\activate
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Install additional dependencies:
  • Install Tesseract OCR:

    • Download the Windows installer from the Tesseract OCR GitHub page.
    • Run the installer and make sure to check download Additional script data option in the installation options.
    • Add the Tesseract installation directory to the system's PATH environment variable.
  • Install FFmpeg:

    • Download the latest static build of FFmpeg for Windows from the official FFmpeg website.
    • Extract the downloaded ZIP file to a location of your choice.
    • Add the FFmpeg bin directory to the system's PATH environment variable.
  1. Run the bot:
python main.py

Docker

Build (change environment variables before build)

docker build -t telegrambot_gpt4free:latest "." 

Docker-compose

docker-compose up --build -d

Environment Variables

To run this project, you will need to create a .env file or rename the existing example.env to .env and add the following environment variables

  • BOT_TOKEN Get this by messaging @botfather Refer to 📖 Telegram Bot Tutorial

  • HG_TOKEN Optional(Required for image captioning). Sign up on hugging face and get the token from 🔗 Hugging Face.

  • HG_img2text Required for image captioning. If you wnat to use another model for image captioning. change it here.
    Default value HG_img2text = 'https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-large'

  • DEFAULT_LANG Change to your language currently English and Russian supported. If you want to translate to your own language please do so in the language_files folder make your own language.yml file and add the language to languages.yml file.

🎉 You're all set! Enjoy using the Telegram bot with ChatGPT!

Contributors