71 Commits
Author SHA1 Message Date
Father Bot 2435e7332b docs: make README intro vendor-neutral (OpenAI + Anthropic)
Drop the chat.openai.com framing in favor of a neutral hook that credits
both OpenAI and Anthropic models.
2026-06-14 13:28:27 +03:00
Father Bot 8676be8b01 Document OpenRouter and Anthropic models in README 2026-06-14 13:09:57 +03:00
Father Bot a7984073b1 Remove unused is_content_acceptable helper
The moderation helper had no callers anywhere in the codebase. Drop
the dead function.
2026-06-05 12:30:00 +03:00
Father Bot 9503791697 Document 1.3.0 in CHANGELOG
Record removal of legacy gpt-3.5-turbo/gpt-4, the token-table
simplification, README refresh and the /balance KeyError fix.
2026-06-04 14:47:09 +03:00
Father Bot ce2049e4f1 Bump version to 1.3.0 2026-06-01 11:30:18 +03:00
Father Bot 9c0250a2a8 Refresh README: drop legacy GPT-4 mentions
Update the title to GPT-5.5 & Claude and remove the stale 'GPT-4 and
GPT-4 Turbo support' feature line now that those models are gone.
2026-05-29 19:05:14 +03:00
Father Bot 068f996473 Simplify token-count overhead table
The per-model if/elif chain only ever set tokens_per_message=3 for
supported models (and 4 for the now-removed gpt-3.5 family). Collapse
it to a single assignment since every current chat model shares the
same overhead.
2026-05-26 10:15:43 +03:00
Father Bot 5d8f98427e Skip unconfigured models in /balance
Existing users may have token usage recorded against models that have
since been removed from models.yml. Skip any model key not present in
the config when building the balance breakdown so /balance no longer
raises a KeyError for them.
2026-05-23 16:41:20 +03:00
Father Bot b0ca129e75 Remove legacy gpt-3.5-turbo and gpt-4 models
Drop the remaining old models from the menu and config. The lineup is
now gpt-4o-mini (default), gpt-5.5, gpt-4o and the Claude models.
2026-05-20 12:09:55 +03:00
Father Bot 131ba9daab Reflect gpt-image-1 in the 1.2.0 changelog
The release switched image generation to gpt-image-1; update the
changelog entry to match the final state.
2026-05-17 18:48:02 +03:00
Father Bot 6676d0b938 Document gpt-image-1 in README
Update the feature list and News entry to reference gpt-image-1
instead of DALL·E 3.
2026-05-14 09:27:38 +03:00
Father Bot 6eead18619 Update example config comments for gpt-image-1
gpt-image-1 supports multiple images per request and the sizes
1024x1024, 1536x1024, 1024x1536 and auto. Update the comments
accordingly.
2026-05-11 13:21:07 +03:00
Father Bot 0dba82f04f Replace dalle-3 with gpt-image-1 in models.yml
Swap the image model entry to gpt-image-1 ($0.042 per 1024x1024
medium-quality image) so /balance reflects the new model.
2026-05-08 20:33:39 +03:00
Father Bot 3b3fab9e06 Send gpt-image-1 images as bytes and update balance
generate_images now returns raw image bytes, so wrap each in BytesIO
for reply_photo instead of passing a URL. Reference the gpt-image-1
price entry in /balance and relabel it 'GPT Image'.
2026-05-05 11:36:29 +03:00
Father Bot 52857fedde Generate images with gpt-image-1
Replace DALL-E 3 with OpenAI's gpt-image-1 model. gpt-image-1 returns
base64-encoded images instead of URLs, so decode each result to raw
bytes and return the list of images.
2026-05-02 17:14:51 +03:00
Father Bot 625210a924 Document 1.2.0 in CHANGELOG
Record DALL-E 3 image generation, updated gpt-4o pricing, removal of
deprecated models and the new CI workflow.
2026-04-29 10:52:46 +03:00
Father Bot 712898cfeb Bump version to 1.2.0 2026-04-26 15:17:33 +03:00
Father Bot 91c9f51f47 Add minimal CI workflow
Add a GitHub Actions workflow that installs requirements on Python
3.12 and byte-compiles the bot package on every push to main and on
pull requests, catching dependency-resolution and syntax errors early.
2026-04-23 12:40:09 +03:00
Father Bot e09e0017b4 Update README for DALL-E 3 and model cleanup
Reflect DALL·E 3 image generation, generalized vision support and the
removal of deprecated models in the feature list and News section.
2026-04-20 18:05:52 +03:00
Father Bot b7f8224606 Update bot to DALL-E 3 for balance and image accounting
Reference the dalle-3 price entry and label balance details as
DALL·E 3, and count actually returned images (len(image_urls))
instead of the configured request count, since DALL-E 3 always
returns a single image.
2026-04-17 14:23:18 +03:00
Father Bot 169406c377 Replace dalle-2 with dall-e-3 pricing in models.yml
Update the image model entry to dalle-3 at $0.04 per 1024x1024 image
so /balance reflects DALL-E 3 costs.
2026-04-14 09:50:40 +03:00
Father Bot f7459df1ad Default image size to 1024x1024 for DALL-E 3
512x512 is not a valid DALL-E 3 size. Default to 1024x1024 and update
the example config to list the supported DALL-E 3 sizes and note the
one-image-per-request limit.
2026-04-11 19:31:07 +03:00
Father Bot 09ebbbf996 Switch image generation to DALL-E 3
Use the dall-e-3 model in generate_images and default to 1024x1024.
dall-e-3 only supports n=1, so request a single image per call.
2026-04-08 11:08:52 +03:00
Father Bot 04174251b5 Update gpt-4o pricing to current rates
gpt-4o was priced at its launch rate (0.005/0.015). OpenAI later cut
it to $2.50 / $10 per 1M tokens; update to 0.0025/0.01 so /balance
reflects current cost.
2026-04-05 16:42:21 +03:00
Father Bot c828549d7a Remove deprecated models from the menu
Drop gpt-3.5-turbo-16k, gpt-4-1106-preview and gpt-4-vision-preview
from available_text_models and their info blocks. All three are
deprecated/retired by OpenAI; gpt-4o and gpt-4o-mini cover their use
cases (including vision).
2026-04-02 10:14:03 +03:00
Father Bot 755f0a7da5 Fix News section: date the 1.1.0 entries and order chronologically 2026-03-31 17:00:40 +03:00
Father Bot 06c6e0f653 Note config-driven vision support in CHANGELOG 2026-03-29 13:25:18 +03:00
Father Bot 33ec9c3ead Route image messages by the config vision flag
bot.py decided vision handling from hardcoded gpt-4o/gpt-4-vision
checks. Use the models.yml 'vision' flag instead: any vision-capable
model (incl. gpt-5.5 and Claude) now handles images directly, and a
photo sent to a non-vision model still falls back to gpt-4o. The
rejection message in the vision handler is updated to match.
2026-03-28 18:05:52 +03:00
Father Bot 16441877b8 Gate vision in openai_utils by the config vision flag
send_vision_message and send_vision_message_stream now accept any
model flagged vision: true in models.yml instead of a hardcoded
gpt-4o/gpt-4-vision set, so Claude and gpt-5.5 can process images.
2026-03-27 09:50:27 +03:00
Father Bot e97a0819c1 Flag vision-capable models in models.yml
Add 'vision: true' to models that can read images: gpt-4o,
gpt-4o-mini, gpt-4-vision-preview, gpt-5.5 and the Claude models.
This lets the bot decide vision support from config instead of
hardcoded model names.
2026-03-25 16:20:33 +03:00
Father Bot 8b36c42694 Document OpenRouter, Claude and GPT-5.5 in README
Add a feature bullet and News entry covering OpenRouter provider
support and the new Claude and GPT-5.5 models.
2026-03-24 11:40:09 +03:00
Father Bot 10daaf47c5 Document 1.1.0 in CHANGELOG
Record OpenRouter provider support, Claude models, gpt-5.5, the
config-driven model dispatch, token-counting fallback and the
settings button layout fix.
2026-03-22 14:15:46 +03:00
Father Bot f7ab294690 Bump version to 1.1.0 2026-03-20 10:30:11 +03:00
Father Bot f239b53086 Lay out settings model buttons in rows of two
The settings menu put every model button in a single row. Telegram
rejects rows with more than 8 inline buttons, which would break
/settings now that the model list is longer. Chunk the buttons into
rows of two.
2026-03-19 15:52:08 +03:00
Father Bot 2ace648aa9 Add Anthropic Claude models via OpenRouter
Add Claude Opus 4.8, Claude Sonnet and Claude Haiku as selectable
chat models, routed through OpenRouter (provider: openrouter). Slugs
and pricing taken from the OpenRouter model list. Requires
openrouter_api_key to be set.
2026-03-15 10:28:36 +03:00
Father Bot dbe426775f Add OpenAI gpt-5.5 model (via OpenRouter)
Add OpenAI's latest flagship gpt-5.5 as a selectable model, routed
through OpenRouter (provider: openrouter, slug openai/gpt-5.5).
Pricing taken from the OpenRouter model list.
2026-03-09 17:14:53 +03:00
Father Bot 8b42181274 Add OpenRouter provider support
Introduce an optional OpenRouter client (OpenAI-compatible) alongside
the OpenAI one. Models can declare 'provider: openrouter' in
models.yml; ChatGPT now selects the matching client per model via
_get_client_for_model and routes chat completions through it. This
unlocks non-OpenAI models (e.g. Claude) through a single SDK.

Adds openrouter_api_key / openrouter_api_base config options.
2026-03-03 12:40:21 +03:00
Father Bot 6af26cc9bc Dispatch chat models by config type, not hardcoded lists
Replace the hardcoded model-name sets in __init__, send_message and
send_message_stream with checks against config/models.yml: the assert
now accepts any model defined in models['info'], and the chat path is
taken for any model whose type is 'chat_completion'. Adding a new
chat model is now a models.yml-only change. Vision handling is left
on its explicit model set for now.
2026-02-28 18:47:09 +03:00
Father Bot ee9dae189f Make token counting robust for non-OpenAI models
tiktoken.encoding_for_model and the per-model token table only know
OpenAI models, so any other model (Claude or anything routed via
OpenRouter) raised. Fall back to the o200k_base encoding and a
default tokens_per_message for unknown models so streaming token
estimates work for every chat model.
2026-02-27 14:22:36 +03:00
Father Bot a6f44166a0 Update README for the modernized release
Note that gpt-4o-mini is the default model and add a News entry for
the openai 1.x SDK migration, the new default and the Python 3.12
image, linking to CHANGELOG.md.
2026-02-26 17:58:31 +03:00
Father Bot c82e4e79d0 Add CHANGELOG for the 1.0.0 release
Document the openai 1.x migration, gpt-4o/gpt-4o-mini support and new
default, Python 3.12 upgrade, dependency bumps, Docker improvements
and the text-davinci-003 removal.
2026-02-22 15:13:02 +03:00
Father Bot 6954e4e9a6 Add VERSION file (1.0.0)
Introduce an explicit version marker for the modernized release.
2026-02-18 20:36:49 +03:00
Father Bot e37eb4a248 Drop text-davinci-003 code paths from openai_utils
Remove the legacy completion handling now that the model is gone:
- drop text-davinci-003 from the __init__ assert
- remove the legacy completions.create branches in send_message and
  send_message_stream
- delete the now-unused _generate_prompt and _count_tokens_from_prompt
  helpers

All remaining paths use the chat completions API.
2026-02-14 12:05:18 +03:00
Father Bot 6b90a74567 Remove text-davinci-003 from models config
OpenAI shut down the legacy text-davinci-003 completions model in
early 2024, so it can no longer be used. Drop it from the available
models list and remove its info block.
2026-02-11 18:42:55 +03:00
Father Bot a32a06ab17 Bump python-dotenv to 1.0.1
Move from the 0.21 series to the stable 1.0.x line.
2026-02-08 09:17:26 +03:00
Father Bot e88059e35b Bump pymongo to 4.6.3
Update the MongoDB driver for bug fixes and Python 3.12 compatibility.
2026-02-05 13:54:40 +03:00
Father Bot 638fcf6d7b Bump PyYAML to 6.0.2
PyYAML 6.0 fails to build against Cython 3 on modern toolchains
(including Python 3.12). 6.0.1+ fixes this; pin 6.0.2.
2026-02-02 19:31:07 +03:00
Father Bot 92b824bc7c Bump python-telegram-bot to 20.8
Move to the latest 20.x release for bug fixes while staying within
the v20 major to avoid the breaking changes introduced in v21.
2026-01-30 10:08:52 +03:00
Father Bot c48d452612 Remove obsolete version key from docker-compose
The top-level 'version' field is deprecated in Compose v2 and only
produces a warning. Drop it.
2026-01-27 16:45:33 +03:00
Father Bot 9bd3f60d59 Upgrade Docker base image to Python 3.12
python:3.8-slim is EOL (security support ended Oct 2024). Move to
python:3.12-slim and drop the pinned setuptools==59.5.0, which
predates 3.12 support; use the current setuptools instead.
2026-01-24 11:20:14 +03:00
Father Bot 8624e97dd2 Default ChatGPT() model arg to gpt-4o-mini
Keep the ChatGPT class fallback model in sync with the new project
default. Callers always pass an explicit model, so this only affects
the no-argument fallback.
2026-01-22 13:48:09 +03:00
Father Bot ea3af7d3aa Reset to gpt-4o-mini (not gpt-3.5-turbo) on /new
new_dialog_handle pins the model on every /new. Point it at the new
default gpt-4o-mini so starting a new dialog no longer drops users
back onto the outdated gpt-3.5-turbo.
2026-01-14 17:22:41 +03:00
Father Bot bdad62174d Default new users to gpt-4o-mini instead of gpt-3.5-turbo
The default model is taken from available_text_models[0] (used by
Database.add_new_user and the registration fallback). Move
gpt-4o-mini to the front so new users start on it; gpt-3.5-turbo is
outdated, while gpt-4o-mini is cheaper, smarter and supports vision.
This also makes it the first option in the /settings menu.
2026-01-06 11:30:18 +03:00
Father Bot 41a13ee5c9 Drop dead price keys from config.example.yml
chatgpt_price_per_1000_tokens, gpt_price_per_1000_tokens and
whisper_price_per_1_min are not read by config.py; pricing is defined
per model in config/models.yml. Remove them from the example to avoid
implying they have any effect.
2025-12-28 19:40:33 +03:00
Father Bot 4365a9b635 Narrow bare excepts to Exception in bot handlers
Replace the two bare 'except:' clauses (is_bot_mentioned and the
error handler fallback) with 'except Exception:' so they no longer
swallow KeyboardInterrupt, SystemExit or asyncio.CancelledError,
which must propagate for clean shutdown and task cancellation.
2025-12-26 13:15:05 +03:00
Father Bot fe126441d7 Expand .dockerignore to trim build context and secrets
Exclude .git, Python bytecode caches, .DS_Store and the local
config.yml/config.env from the Docker build context so they are not
sent to the daemon or baked into the image.
2025-12-24 16:29:42 +03:00
Father Bot 1bc081d115 Live-mount config dir in docker-compose
Mount ./config into the bot container so config.yml / models.yml /
chat_modes.yml changes take effect with a simple restart instead of
a full image rebuild. Addresses #124.
2025-12-22 11:48:17 +03:00
Father Bot 8d9897d580 Set PYTHONUNBUFFERED=1 for immediate log output
Without unbuffered output the bot's stdout/stderr can sit in a
buffer, so 'docker logs' shows nothing until the buffer flushes.
Set PYTHONUNBUFFERED=1 so log lines appear in real time.
2025-12-21 21:03:50 +03:00
Father Bot a79d1cfbf3 Use pip --no-cache-dir to shrink the Docker image
Disable pip's download cache during the image build so the wheel
cache is not baked into the final layers, reducing image size.
Addresses #186.
2025-12-19 15:12:09 +03:00
Father Bot fc0cac03ab Use openai.BadRequestError in image generation handler
Follow-up to the openai 1.x migration: the legacy
openai.error.InvalidRequestError no longer exists in the 1.x SDK.
Catch openai.BadRequestError when DALL-E rejects a prompt.
2025-12-18 09:37:31 +03:00
Father Bot d48276616a Migrate openai_utils to the openai 1.x SDK
Replace the deprecated module-level openai 0.28 API with the new
AsyncOpenAI client:
- instantiate AsyncOpenAI(api_key, base_url) instead of setting
  openai.api_key / openai.api_base globals
- ChatCompletion.acreate -> client.chat.completions.create
- Completion.acreate(engine=...) -> client.completions.create(model=...)
- Audio.atranscribe -> client.audio.transcriptions.create
- Image.acreate -> client.images.generate
- Moderation.acreate -> client.moderations.create (use .flagged)
- attribute access for message/delta content (.content instead of
  dict access) and guard empty streaming choices
- rename request_timeout option to timeout
- catch openai.BadRequestError instead of openai.error.InvalidRequestError

Bump openai to >=1.40.0,<2.0.0. Requires testing against the API.
2025-12-16 18:54:48 +03:00
Father Bot b4528a2328 Fix date typo in README changelog (Apt -> Apr) 2025-12-15 10:26:14 +03:00
Father Bot cb4f55850a Fix typo in gpt-4-vision description (capabilties -> capabilities) 2025-12-13 17:41:55 +03:00
Father Bot c8ffae21ad Bump tiktoken to >=0.7.0 for gpt-4o token counting
gpt-4o and gpt-4o-mini use the o200k_base encoding, which tiktoken
only ships from 0.7.0 onwards. With the previous >=0.3.0 pin
tiktoken.encoding_for_model("gpt-4o") raises, breaking token
counting in streaming mode for those models.
2025-12-11 12:08:26 +03:00
Father Bot 95a475f5a0 Document GPT-4o and GPT-4o mini support in README
Add GPT-4o / GPT-4o mini to the feature list and News section so the
docs reflect the models now available in /settings.
2025-12-10 20:33:39 +03:00
Father Bot 91f6880f23 Stop tracking .DS_Store
Remove the committed macOS .DS_Store file from the index and add it
to .gitignore so it does not get re-committed.
2025-12-08 14:50:12 +03:00
Father Bot 7123bd14a1 Remove leftover debug logging in message handler
logger.error(current_model) fired on every incoming message and
spammed the error log with the model name; the accompanying
'# What is this? ^^^' note was dead. Drop both; the vision
auto-switch logic is unchanged.
2025-12-07 09:21:57 +03:00
Father Bot 43aa46a872 Add gpt-4o-mini model support
Wire gpt-4o-mini through the bot: register it in models.yml
(available list + pricing/scores entry) and add it to the model
sets in openai_utils (chat, streaming, vision and token counting).
gpt-4o-mini is cheaper and smarter than gpt-3.5-turbo and supports
images, so it is a good default-grade option. Addresses #474.
2025-12-05 19:05:44 +03:00
Father Bot 148b3b8268 Normalize model score labels to capitalized form
gpt-4-1106-preview, gpt-4-vision-preview and gpt-4o used lowercase
score keys (smart/fast/cheap) while the rest used capitalized ones.
These keys are shown verbatim as labels in /settings, so normalize
them for consistent display.
2025-12-04 11:32:08 +03:00
Father Bot 7416a7edd6 Fix gpt-4o scores: it is faster and cheaper than gpt-4
gpt-4o was scored fast:2 cheap:2 (same as plain gpt-4), which is
misleading. Bump to fast:4 cheap:4 to reflect its actual profile.
2025-12-02 16:47:21 +03:00
Father Bot 3aab56a21a Fix incorrect gpt-4o pricing in models.yml
gpt-4o was priced at gpt-4 rates (0.03/0.06). Correct to actual
0.005/0.015 per 1k tokens so the /balance report is accurate.
2025-12-01 10:14:03 +03:00