It is OpenAI telegram bot that can use any OpenAI model. It uses simple auth via private Telegram group - bot will not work with users that are not members of some certain private group.
- python3
- shell (zsh, bash, sh)
- Docker (for running conterized)
- Register at https://platform.openai.com/
- Create new API key: https://platform.openai.com/account/api-keys. Save it somewhere.
- Create telegram bot via message to https://t.me/BotFather. Save bot token somewhere.
- Create private group and add bot to it. Save somewhere ID of the group (ex. '-123456789'). You can find group ID in Telegram Web by opening the group and get ID from URL - like https://web.telegram.org/k/#-123456789, where ID is
-123456789
- Add trusted users to private group you created.
- (optional) Create .env file with variables you need.
make venv # create virtual env for Python
make env # create .env from .env.dist
make install # install deps
You can set TELEGRAM_AUTH_GROUP_ID
, TELEGRAM_BOT_TOKEN
, OPENAI_API_KEY
and other variables in your env.
Or you can pass it to python directly.
TELEGRAM_AUTH_GROUP_ID='...' TELEGRAM_BOT_TOKEN='...' OPENAI_API_KEY='...' python3 server.py
env name | default value | description |
---|---|---|
TELEGRAM_AUTH_GROUP_ID (required) |
undefined | id of private telegram group. Ex. '-123456789' |
TELEGRAM_BOT_TOKEN (required) |
undefined | telegram bot token |
OPENAI_API_KEY (required) |
undefined | |
TELEGRAM_BOT_ALIAS | undefined | telegram bot username. Ex. '@your_bot_username' |
TELEGRAM_ADMIN_NICKNAME | bot's admin |
Ex. '@your_user' |
RESPONSE_TIMEOUT | 300 |
Timeout for OpenAI API response |
MAX_MODEL_TOKENS | 1000 |
|
MODEL_ID | gpt-3.5-turbo |
ID of model to use. See compatibility with MODEL_TYPE here: https://platform.openai.com/docs/models/model-endpoint-compatibility |
MODEL_TYPE | chat |
Can be chat or competition . You must set this value with MODEL_ID |
CONVERSATIONS_TIMEOUT | 604800000 |
timeout before conversation will be cleaned, in ms |
docker run --name openai --rm -d \
-e TELEGRAM_AUTH_GROUP_ID='...' \
-e TELEGRAM_BOT_TOKEN='...' \
-e OPENAI_API_KEY='...'\
kemmor/openai-telegram-bot:latest
docker run --name openai --rm -d --env-file .env kemmor/openai-telegram-bot:latest
The MIT License (MIT)