init
This commit is contained in:
commit
ec1112e162
22 changed files with 837 additions and 0 deletions
130
bot/prompts/synthesis.py
Normal file
130
bot/prompts/synthesis.py
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
from bot.models import ReportType
|
||||
|
||||
_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}
|
||||
"""
|
||||
|
||||
_CONTENT = """\
|
||||
Synthesize the chunk summaries into a comprehensive **Content Analysis Report** with these sections:
|
||||
|
||||
## Overview
|
||||
Brief channel description and positioning.
|
||||
|
||||
## Key Topics & Themes
|
||||
Main subject areas with examples.
|
||||
|
||||
## Tone & Communication Style
|
||||
How the channel communicates with its audience.
|
||||
|
||||
## Content Strategy
|
||||
Formats used, posting patterns, narrative arcs.
|
||||
|
||||
## Notable Content
|
||||
Standout posts or recurring motifs.
|
||||
|
||||
## Summary
|
||||
Key takeaways in 3-5 bullet points.
|
||||
|
||||
Use Telegram-friendly formatting (bold, bullet points). Be specific — reference actual content patterns you observed."""
|
||||
|
||||
_CONTENT_STATS = """\
|
||||
Synthesize the chunk summaries into a comprehensive **Content & Stats Report** with these sections:
|
||||
|
||||
## Overview
|
||||
Brief channel description, subscriber count, and overall activity level.
|
||||
|
||||
## Key Topics & Themes
|
||||
Main subject areas ranked by frequency and engagement.
|
||||
|
||||
## Tone & Communication Style
|
||||
How the channel communicates with its audience.
|
||||
|
||||
## Content Strategy
|
||||
Formats used, posting patterns, narrative arcs.
|
||||
|
||||
## Engagement Analysis
|
||||
- Average engagement patterns
|
||||
- Top-performing content types
|
||||
- Engagement trends over time
|
||||
|
||||
## Posting Patterns
|
||||
Frequency, schedule consistency, any notable gaps or bursts.
|
||||
|
||||
## Summary
|
||||
Key takeaways in 5-7 bullet points mixing qualitative and quantitative insights.
|
||||
|
||||
Use Telegram-friendly formatting. Include specific numbers where available."""
|
||||
|
||||
_FULL_AUDIT = """\
|
||||
Synthesize the chunk summaries into a comprehensive **Full Channel Audit** with these sections:
|
||||
|
||||
## Executive Summary
|
||||
Channel positioning, key metrics, and overall assessment.
|
||||
|
||||
## Key Topics & Themes
|
||||
Main subject areas ranked by frequency and engagement, with trend analysis.
|
||||
|
||||
## Tone & Communication Style
|
||||
Detailed analysis of voice, register, and audience relationship.
|
||||
|
||||
## Content Strategy Assessment
|
||||
Formats, patterns, narrative arcs — what works and what doesn't.
|
||||
|
||||
## Engagement Deep Dive
|
||||
- Engagement metrics and benchmarks
|
||||
- Top-performing vs underperforming content
|
||||
- Engagement drivers and detractors
|
||||
|
||||
## Sentiment Analysis
|
||||
Overall sentiment distribution, sentiment by topic, shifts over time.
|
||||
|
||||
## Audience Insights
|
||||
Inferred audience profile, interaction patterns, community dynamics.
|
||||
|
||||
## Strengths
|
||||
What the channel does well (3-5 points with evidence).
|
||||
|
||||
## Areas for Improvement
|
||||
Actionable recommendations (3-5 points with specific suggestions).
|
||||
|
||||
## Strategic Recommendations
|
||||
Forward-looking advice for channel growth and content optimization.
|
||||
|
||||
Use Telegram-friendly formatting. Be specific — back every claim with observed patterns or data."""
|
||||
|
||||
SYNTHESIS_PROMPTS = {
|
||||
ReportType.CONTENT: _CONTENT,
|
||||
ReportType.CONTENT_STATS: _CONTENT_STATS,
|
||||
ReportType.FULL_AUDIT: _FULL_AUDIT,
|
||||
}
|
||||
|
||||
|
||||
def build_synthesis_prompt(
|
||||
report_type: ReportType,
|
||||
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,
|
||||
)
|
||||
return base + "\n" + SYNTHESIS_PROMPTS[report_type]
|
||||
Loading…
Add table
Add a link
Reference in a new issue