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)