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
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
from bot.models import Depth, FocusArea
|
|
from bot.prompts.depth import DEPTH_SYNTHESIS_MODIFIERS
|
|
from bot.prompts.focus_areas import FOCUS_SYNTHESIS_SECTIONS
|
|
|
|
_BASE = """\
|
|
You are producing a final report for a Telegram channel analysis.
|
|
|
|
Channel: {title} (@{username})
|
|
Subscribers: {subscribers}
|
|
Total messages analyzed: {msg_count}
|
|
Analysis chunks: {chunk_count}
|
|
|
|
Below are the summaries from each chunk of the channel's history:
|
|
|
|
{chunk_summaries}
|
|
"""
|
|
|
|
|
|
def build_synthesis_prompt(
|
|
depth: Depth,
|
|
focus_areas: list[FocusArea],
|
|
lang: str,
|
|
title: str,
|
|
username: str | None,
|
|
subscribers: int | None,
|
|
msg_count: int,
|
|
chunk_summaries: list[str],
|
|
) -> str:
|
|
numbered = "\n\n".join(
|
|
f"### Chunk {i+1}\n{s}" for i, s in enumerate(chunk_summaries)
|
|
)
|
|
base = _BASE.format(
|
|
title=title,
|
|
username=username or "N/A",
|
|
subscribers=subscribers or "N/A",
|
|
msg_count=msg_count,
|
|
chunk_count=len(chunk_summaries),
|
|
chunk_summaries=numbered,
|
|
)
|
|
parts = [base]
|
|
|
|
parts.append("Synthesize the chunk summaries into a comprehensive report with these sections:\n")
|
|
parts.append("## Overview\nBrief channel description and positioning.\n")
|
|
|
|
for area in focus_areas:
|
|
parts.append(FOCUS_SYNTHESIS_SECTIONS[area] + "\n")
|
|
|
|
parts.append("## Key Takeaways\nSummarize the most important findings.\n")
|
|
|
|
parts.append(DEPTH_SYNTHESIS_MODIFIERS[depth])
|
|
parts.append(f"\nWrite the entire report in {'Russian' if lang == 'ru' else 'English'}.")
|
|
parts.append("Use Telegram-friendly formatting (bold, bullet points). Be specific — reference actual content patterns.")
|
|
|
|
return "\n".join(parts)
|