Giter VIP home page Giter VIP logo

forty-two's Introduction

Forty-two is a Telegram bot that allows you to create your own ChatGPT in Telegram with OpenAI GPT, Google Gemini and Anthropic Claude models.

Features

  • Easy to use and deploy. You just need to set the Telegram and OpenAI/Gemini/Anthropic API keys and run the bot.
  • Switching between different AI providers with saving the correspondence history.
  • Ask another AI provider for a response to the same question.
  • GPT Vision. You can send images to the bot and ask questions about them.
  • Track your conversation history with GPT.
  • Limit users who can interact with the bot.
  • Log user messages to a file and the console.
  • i18n for system messages. Currently, supports English, Spanish, Catalan and Russian.
  • Fully asynchronous.
  • MIT License.

Setup

1. Create a .env file with the following content:

TELEGRAM_TOKEN=your_telegram_api_key
OPENAI_API_KEY=your_openai_api_key
# and / or
# GEMINI_API_KEY=your_gemini_api_key
# ANTHROPIC_API_KEY=your_anthropic_api_key

2. Run the bot

With docker-compose:

docker-compose up -d

Run without Docker:

pip install -r requirements.txt
alembic upgrade head
python main.py

Settings

Variable Description Default Value
TELEGRAM_TOKEN Telegram API key. -
OPENAI_API_KEY OpenAI API key. -
GEMINI_API_KEY Google Gemini API key. -
ANTHROPIC_API_KEY Anthropic API key. -
PROVIDER Default provider for users. Users then can change their default provider with /provider command. Please note that API_KEY for selected provider is required. OPENAI
DB_STRING Database connection string. sqlite+aiosqlite:///db.sqlite3
MAX_COMPLETION_TOKENS Maximum tokens for completion. 4096
MAX_TOTAL_TOKENS Maximum tokens for total output. If AI provider uses more than this amount, the bot will summarize user input. 10000
SYSTEM_PROMPT System prompt for GPT. You are a friendly assistant, your name is Rick
OPENAI_MODEL OpenAI model. gpt-4o
ANTHROPIC_MODEL Anthropic model. claude-3-5-sonnet-20240620
GEMINI_MODEL Gemini model. gemini-1.5-flash
ALLOWED_USERS Comma-separated list of Telegram users who can interact with the bot. You can use both Telegram IDs or Usernames. If None, everyone can interact with the bot. Example: durov,238373289 None
LOG_MESSAGES Log user messages to a file and the console. False
HISTORY_EXPIRATION If the last message from a user occurred more than the specified time in minutes, the message history will be reset. 30
LANGUAGE Language for bot system messages. Curretly support en, es, ca, ru. en

Obtaining API keys

In development

  • DALL-E generation.

License

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

Made with love in Barcelona

forty-two's People

Contributors

kolger avatar leksuss avatar

Stargazers

Kyrylo Havrylenko avatar  avatar Alexander Druzhinin avatar Ivan Vinokurov avatar  avatar Viktor Marchenko avatar Vladimir avatar Maxim Cheremisin avatar  avatar

Watchers

 avatar Kostas Georgiou avatar

Forkers

leksuss

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.