- Text generation ✔️
- Image generation ✔️
- Speech-to-text ✔️
- Inline mode support ✔️
- Private chat support ✔️
- Access management system with different levels of access ✔️
- Group chat support
coming soon
git clone https://github.com/satojkee/ayumi-bot.git
pip3 install -r requirements.txt
Set each property using
.env
file or viacli
Variable | Description | Hint |
---|---|---|
DATABASE_URI |
Database credentials | PostgreSQL + asyncpg, format: postgresql+asyncpg://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB} |
TELEGRAM_TOKEN |
Telegram bot token | visit BotFather and create your own bot |
TELEGRAM_OWNER_ID |
Telegram admin id | use GetIDsBot to get your account id |
TELEGRAM_BOT_NAME |
Telegram bot name | this name is used as filter for prompts, e.g: TELEGRAM_BOT_NAME, hello! or TELEGRAM_BOT_NAME@i, image of a cute kitten. |
OPENAI_PROJECT_ID |
OpenAI project ID | visit OpenAI and create a new project |
OPENAI_SECRET_KEY |
OpenAI API token | create a new API-KEY for a created project on OpenAI platform |
Used in docker-compose case, don't forget to build a
DATABASE_URI
in proper way
Example:postgresql+asyncpg://postgres:postgres_secret@postgres:5432/test_database
Variable | Description | Hint |
---|---|---|
POSTGRES_USER |
Database user | postgres for example |
POSTGRES_PASSWORD |
Database password | postgres_secret for example |
POSTGRES_DB |
Database name | test_database for example |
For example, you can replace the
gpt-4o-mini
text-model withgpt-3.5-turbo
orgpt-4o
, but don't forget to enable this model in your project settings on OpenAI platform
security
- levels - a list of supported security levels in ascending order
- zero - this value is used in keyboard.access_keyboard and handlers.admin.access_callback to represent negative access response
security.ai
- define required security levels for AI features here
- textgen - security level to access text generation feature
- textgen_inline - security level to access text generation in inline mode
- speech_to_text - security level to access speech-to-text feature
- imagegen - security level to access image generation feature
inline.query
- min_len - min length of a prompt in inline mode
locale
- languages - a list of supported languages
logger
- level - logger level, supported levels:
- DEBUG -
default
- INFO
- WARNING
- ERROR
- CRITICAL
openai
- directive - Answers the question: "How to act?", for textgen and textgen_inline
locale.translator
- supports all gettext.translation function params
openai.text
- supports all openai.client.chat.completion.create function params
openai.image
- supports all openai.client.images.generate function params
openai.speech_to_text
- supports all openai.client.audio.transcriptions.create function params
sqlalchemy
- supports all SQLAlchemy.create_async_engine function params
[security]
levels = [1, 2, 3]
zero = 0
[security.ai]
textgen = 1
textgen_inline = 1
speech_to_text = 2
imagegen = 3
[sqlalchemy]
pool_pre_ping = false
echo = false
[locale]
languages = ["en", "uk"]
[locale.translator]
domain = "messages"
localedir = "locale"
[logger]
level = "DEBUG"
[openai]
directive = "Your name is Ayumi. You are a helpful telegram chat assistant. Act like a human. Respond in language you are asked."
[openai.text]
model = "gpt-4o-mini"
[openai.image]
size = "1024x1024"
model = "dall-e-3"
[openai.speech_to_text]
response_format = "text"
model = "whisper-1"
[inline.query]
min_len = 3
python main.py --help
Current version of Ayumi supports only async version of
SQLAlchemy
(tested only withPostgreSQL
database andasyncpg
driver).
python main.py --reinit
Don't forget to configure
inline
mode for your bot withsetinline
command via BotFather
ONLY IF YOU WANT TO USE THIS FEATURE ^^
python main.py
Don't forget to set required variables in
Dockerfile
or directly indocker run --env ...
docker build -t ayumi .
docker run --env ... ayumi
Create .env
file in the project root and configure all required + additional variables.
The
ayumi_bot
container may restart several times, due to the longpostgres
container init
docker-compose up -d
PyBabel automatically extracts all strings (values inside
gettext
function) from your sources
pybabel extract . -o locale/base.pot
pybabel init -l en -i locale/base.pot -d locale
Always use this after
extraction
pybabel update -i locale/base.pot -d locale
Compiles
messages.po
tomessages.mo
files
pybabel compile -d locale