pysergio/hiroshi

By pysergio

Updated about 5 hours ago

Just a GPT4Free-based ChatGPT Telegram bot

Image
Machine Learning & AI

6.7K

logo

Builddocker image archlicense

Hiroshi is a GPT4Free-based Telegram chatbot that offers 100% free access to interact with GPT-3.5, GPT-4, and Llama2 language models, inclusive of Bing, You, AI Chat, and more. Users have the freedom to select their preferred model or specific provider. Do note, the speed/stability may be slightly diminished when working with certain providers. Conversation context is fully retained when you switch between models and providers.

Note: This bot provides access to public free services. The quality and speed of such services can vary depending on various conditions and their current load. If you need a bot that uses the official OpenAI API and you have an API KEY, please check the following repository: https://github.com/s-nagaev/chibi.

Supported platforms

  • linux/amd64
  • linux/arm64 (Raspberry Pi 4+ is supported!)

Features

  • Access to language models such as GPT-3.5, GPT-4, Llama2.
  • Ability to choose a specific model or provider, with the fastest and most available provider automatically selected for the chosen model.
  • Customizable storage time for conversation history.
  • Preservation of conversation history even when changing providers or models.
  • Pre-configured for quick setup, requiring only a Telegram bot token to get started.
  • Cross-platform support (amd64, arm64).
  • MIT License.

Can I try it?

Sure! @hiroshi_gpt_bot

System Requirements

The application is not resource-demanding at all. It works perfectly on the minimal Raspberry Pi 4 and the cheapest AWS EC2 Instance t4g.nano (2 arm64 cores, 512MB RAM), while being able to serve many people simultaneously.

Prerequisites

  • Docker
  • Docker Compose (optional)

Getting Started

Using Docker Run
  1. Pull the Hiroshi Docker image:

    docker pull pysergio/hiroshi:latest
    
  2. Run the Docker container with the necessary environment variables:

    docker run -d \
      -e TELEGRAM_BOT_TOKEN=<your_telegram_token> \
      -v <path_to_local_data_directory>:/app/data \
      --name hiroshi \
      pysergio/hiroshi:latest
    

    Replace <your_telegram_token> and <path_to_local_data_directory> with appropriate values.

Using Docker Compose
  1. Create a docker-compose.yml file with the following contents:

       version: '3'
    
       services:
         hiroshi:
          restart: unless-stopped
          image: pysergio/hiroshi:latest
          environment:
            TELEGRAM_BOT_TOKEN: <your_telegram_token>
          volumes:
            - hiroshi_data:/app/data
       
       volumes:
         hiroshi_data:
    

    Replace <your_telegram_token> with appropriate values.

  2. Run the Docker container:

    docker-compose up -d
    

Please, visit the examples directory of the current repository for more examples.

Configuration

You can configure Hiroshi using the following environment variables:

VariableDescriptionRequiredDefault Value
TELEGRAM_BOT_TOKENYour Telegram bot tokenYes
ALLOW_BOTSAllow other bots to interact with HiroshiNofalse
ANSWER_DIRECT_MESSAGES_ONLYIf True the bot in group chats will respond only to messages, containing its name (see the BOT_NAME setting)NOtrue
ASSISTANT_PROMPTInitial assistant prompt for OpenAI ClientNo"You're helpful and friendly assistant. Your name is Hiroshi"
BOT_NAMEName of the botNo"Hiroshi"
GROUPS_WHITELISTComma-separated list of whitelisted group IDs, i.e "-799999999,-788888888"No
LOG_PROMPT_DATALog user's prompts and GPT answers for debugging purposes.Nofalse
MAX_CONVERSATION_AGE_MINUTESMaximum age of conversations (in minutes)No60
MAX_HISTORY_TOKENSMaximum number of tokens in conversation historyNo1800
MESSAGE_FOR_DISALLOWED_USERSMessage to show disallowed usersNo"You're not allowed to interact with me, sorry. Contact my owner first, please."
PROXYProxy settings for your applicationNo
REDISRedis connection string, i.e. "redis://localhost"No
REDIS_PASSWORDRedis password (optional)No
RETRIESThe number of retry requests to the provider in case of a failed responseNo2
TIMEOUTTimeout (in seconds) for processing requestsNo60
USERS_WHITELISTComma-separated list of whitelisted usernames, i.e. "@YourName,@YourFriendName,@YourCatName"No

Please, visit the examples directory for the example of .env-file.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Docker Pull Command

docker pull pysergio/hiroshi