Commit Graph

34 Commits

Author SHA1 Message Date
melod1n 4c2a5471df utils: add shared locks, queues, rendering and message helpers 2026-05-10 22:52:25 +03:00
melod1n d666244863 storage: persist message attachments and user AI settings 2026-05-10 22:52:10 +03:00
melod1n 28f67aefc2 config: add env schema and localization foundation 2026-05-10 22:51:52 +03:00
melod1n 35354a86de refactor: centralize runtime config loading
- Move .env parsing and runtime config reload logic into Environment
- Reload runtime config and system prompt when source files change
- Gate unsafe eval and file tools behind explicit environment flags
- Rename datetime tool to get_datetime and improve tool prompts
- Return structured weather tool responses
- Preserve assistant thinking and aggregate tool calls across stream chunks
2026-05-03 19:45:18 +03:00
melod1n 2fc60806ff feat(ollama): add tool calling support
Add Ollama tool integration for web search, weather, datetime, filesystem operations, and shell evaluation. Implement multi-round tool call handling, streaming updates, thinking cleanup, and safer path validation for file tools.

Also add related environment configuration, command execution helper, MarkdownV2 cancel handling fixes, and remove unused TryAgain callback command.
2026-05-03 15:16:14 +03:00
melod1n 13b41c3026 bump libs
migrate to typescript 6
remove ytdl feature
2026-05-01 07:05:17 +03:00
melod1n 0f91e43ea0 feat: add Ollama audio transcription and runtime config reload
- add audio capability reporting for Ollama models
- support Telegram voice messages via ffmpeg conversion and Ollama transcription
- add USE_SYSTEM_PROMPT toggle and runtime reloading of .env/system prompt settings
- support ollama_options.json for custom Ollama request options
- improve Telegram MarkdownV2 escaping and formatting preservation
- add environment setters for AI provider credentials and models
- show audio capability in info/model commands
2026-05-01 05:09:10 +03:00
melod1n a7fcb8074c improvements, fixes 2026-04-29 19:48:38 +03:00
melod1n d41a4ed3ea improve replies, formatting and system prompt handling 2026-04-29 19:13:28 +03:00
melod1n 860182d409 add policies for future 2026-03-18 13:44:19 +03:00
melod1n 1f96e3553e * environment variable to enable/disable processing links in messages (for downloading videos)
* bot will not automatically download video from youtube or load it from cache. It will fetch video info first, then suggest to download or get video from cache (with retry options)
* some rewriting in sending/editing/replying to messages
2026-03-03 00:01:44 +03:00
melod1n 69ae37e05e /ae command now available if specifically set to 2026-02-16 19:50:07 +03:00
melod1n 2c7824ebc8 (feat): add image generation from openai 2026-02-12 18:21:29 +03:00
melod1n 2026c673f5 checking models capabilities 2026-02-12 14:22:43 +03:00
melod1n 9ba3d81a21 feat(ai): add configurable default provider + refactor telegram handlers
- add AiProvider enum and DEFAULT_AI_PROVIDER env var (fallback: OLLAMA)
- route chat execution based on selected provider (Ollama/Gemini/Mistral/OpenAI)
- move inline query / callback / edited message / my_chat_member handlers into utils
- minor cleanup (command requirements placement, whitespace)
2026-02-04 12:55:04 +03:00
melod1n 3c7d56b213 support for custom baseURL for OpenAI
fix messages' type in context chain
2026-02-04 12:16:31 +03:00
melod1n 639c8ed9d0 update default OpenAI model 2026-02-03 13:55:50 +03:00
melod1n a736f786c2 feat(openai): add chat streaming and model commands
- add /openai (/chatgpt) chat command using OpenAI Responses API (streaming + incremental edits)
- add /openAIListModels, /openAIGetModel, /openAISetModel
- introduce base Command class and migrate non-chat commands to it
- wire OpenAI client + env vars (OPENAI_API_KEY, OPENAI_MODEL)
- bump deps (@google/genai, systeminformation, @types/node) and add openai
2026-02-03 13:39:01 +03:00
melod1n 810151263d feat: separate Ollama text/image/think models + add YouTube downloader
Support OLLAMA_IMAGE_MODEL and new OLLAMA_THINK_MODEL (both default to OLLAMA_MODEL)

Add /ollamathink command; validate thinking capability; disable image-analysis flow in think mode

Make /ollama-get-model show Text/Image/Think blocks only when models differ

Add /ytdl (/youtube) command + auto-detect YouTube URLs in messages

Cache downloaded videos to data/video and schedule daily cleanup

Move photo storage from data/temp to data/photo; improve env boolean parsing via ifTrue

Update deps (youtubei.js, puppeteer*) and TS config (allowJs, allowSyntheticDefaultImports)
2026-01-31 19:37:25 +03:00
melod1n 23052fae0f separate ollama text & image models 2026-01-31 18:07:22 +03:00
melod1n 9e30086af2 fix(images): cache Telegram photos by unique_id and pass base64 to LLM commands
Stop reading image files inside gemini/mistral commands; use pre-encoded image data from message parts

Rework loadImagesIfExists / loadImagesFromFileIds to return cached file_unique_ids and download only missing sizes

Encode cached images to base64 when assembling the reply chain

Make getPhotoMaxSize synchronous (returns PhotoSize), and map to URL only when needed

Await MessageStore.put / UserStore.put and prefetch single-image downloads on message receipt
2026-01-29 20:58:08 +03:00
melod1n b74e0a0f3e refactor(bot): centralize runtime state; support albums + safer vision handling
- make MessageStore.put() return StoredMessage and allow collectReplyChainText() to work with StoredMessage
- move muted users + answers loading into Environment (add Answers model + GEMINI_IMAGE_MODEL)
- extract message handling into processNewMessage() and add media-group (album) caching/downloading by unique_file_id
- for Ollama: check model capabilities before sending images; use replyToMessage helper consistently
- add /geminiGenImage command stub for Gemini image generation
2026-01-29 20:01:30 +03:00
melod1n 8cf1773926 update default gemini model 2026-01-28 18:35:24 +03:00
melod1n 12d9591109 some improvements for prompt making 2026-01-28 17:59:53 +03:00
melod1n 63c64dfa8e update error logging
cutting all kind of prefixes for prompt making
2026-01-28 16:40:29 +03:00
melod1n 32baaebb93 update regex matching - now bot responds only for base commands (like /ping) and with mention (like /ping@panfilovi4_bot) and ignores command if it mentions other bot;
Add ability to see, change and list gemini, mistral and ollama models
2026-01-20 08:31:05 +03:00
melod1n c31345a3eb add update bot's commands on every start and added only for creator mode 2026-01-18 17:39:30 +03:00
melod1n ad8e3115db add gemini and mistral models to environment 2026-01-16 19:03:21 +03:00
melod1n c491329d4f optional usage of names in prompt 2026-01-16 16:13:10 +03:00
melod1n 326cfcafc8 /mistral command for chat with Mistral AI 2026-01-16 15:40:15 +03:00
melod1n 123bda888f move max_photo_size to environment variable 2026-01-12 19:41:40 +03:00
melod1n 8fe6857345 updates 2026-01-12 16:44:21 +03:00
melod1n c6faa19cb0 updates 2026-01-12 16:30:16 +03:00
melod1n df9471a7e4 refactor!: rewrite bot core; add AI (Ollama, Gemini), DB, new commands 2026-01-12 15:32:50 +03:00