tg-channel-analysis/bot/prompts/chunk_summary.py
Sergei Poljanski c30b7e4675 Add multi-user features: i18n, payments, multi-model AI, focus areas
Replace single report type with composable analysis: depth levels
(basic/standard/full) + focus area multi-select (psychology, business,
marketing, content, audience, sentiment). Multi-step inline keyboard
flow guides users through selection.

- i18n: English + Russian, auto-detect from Telegram, /lang override
- AI providers: Anthropic + OpenRouter via AIClient abstraction
- Telegram Stars payments with per-depth pricing and free trial
- SQLite (aiosqlite) for users, analyses, payments tracking
- User middleware for auto-registration and language detection
- Report persistence: save .md locally, offer file download
- New commands: /features, /prices, /lang
- Composable prompt system: depth modifiers + focus area fragments
2026-02-23 01:18:12 +02:00

41 lines
999 B
Python

from bot.models import Depth, FocusArea
from bot.prompts.depth import DEPTH_CHUNK_MODIFIERS
from bot.prompts.focus_areas import FOCUS_CHUNK_BULLETS
_BASE = """\
You are analyzing a batch of Telegram channel posts. Extract structured insights from this chunk.
Channel: {title}
Chunk {chunk_idx} of {total_chunks}
Posts:
{chunk_text}
"""
def build_chunk_prompt(
depth: Depth,
focus_areas: list[FocusArea],
lang: str,
title: str,
chunk_text: str,
chunk_idx: int,
total_chunks: int,
) -> str:
base = _BASE.format(
title=title,
chunk_idx=chunk_idx,
total_chunks=total_chunks,
chunk_text=chunk_text,
)
parts = [base]
parts.append(f"Depth: {DEPTH_CHUNK_MODIFIERS[depth]}\n")
parts.append("Focus on the following areas:")
for area in focus_areas:
parts.append(FOCUS_CHUNK_BULLETS[area])
parts.append(f"\nProvide the analysis in {'Russian' if lang == 'ru' else 'English'}.")
return "\n".join(parts)