added RAG, Multiuser, TG bot

This commit is contained in:
2026-06-14 06:26:16 +00:00
parent c8a9429bed
commit 0c8ab6018a
24 changed files with 1280 additions and 479 deletions
+27
View File
@@ -0,0 +1,27 @@
from __future__ import annotations
from aiogram import Bot
TG_MAX_LEN = 4096
def split_telegram_message(text: str, limit: int = TG_MAX_LEN) -> list[str]:
if len(text) <= limit:
return [text]
chunks: list[str] = []
remaining = text
while remaining:
if len(remaining) <= limit:
chunks.append(remaining)
break
split_at = remaining.rfind("\n", 0, limit)
if split_at <= 0:
split_at = limit
chunks.append(remaining[:split_at])
remaining = remaining[split_at:].lstrip("\n")
return chunks
async def send_text(bot: Bot, chat_id: int, text: str) -> None:
for chunk in split_telegram_message(text):
await bot.send_message(chat_id, chunk)