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
This commit is contained in:
parent
8a84145e15
commit
c30b7e4675
27 changed files with 1155 additions and 280 deletions
|
|
@ -1,4 +1,6 @@
|
|||
from bot.models import ReportType
|
||||
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.
|
||||
|
|
@ -10,52 +12,11 @@ Posts:
|
|||
{chunk_text}
|
||||
"""
|
||||
|
||||
_CONTENT = """\
|
||||
Focus on:
|
||||
- Main topics and themes discussed
|
||||
- Tone and communication style
|
||||
- Content formats (long-form, short updates, lists, etc.)
|
||||
- Key narratives or recurring ideas
|
||||
- Notable quotes or standout posts
|
||||
|
||||
Provide a concise structured summary."""
|
||||
|
||||
_CONTENT_STATS = """\
|
||||
Focus on:
|
||||
- Main topics and themes discussed
|
||||
- Tone and communication style
|
||||
- Content formats used
|
||||
- Key narratives or recurring ideas
|
||||
- Posting frequency patterns in this batch
|
||||
- Engagement patterns (which topics get more views/forwards/replies)
|
||||
- Any notable spikes or drops in engagement
|
||||
|
||||
Provide a concise structured summary with both qualitative and quantitative observations."""
|
||||
|
||||
_FULL_AUDIT = """\
|
||||
Focus on:
|
||||
- Main topics and themes discussed
|
||||
- Tone and communication style
|
||||
- Content formats used
|
||||
- Key narratives or recurring ideas
|
||||
- Posting frequency patterns
|
||||
- Engagement patterns with specific numbers
|
||||
- Sentiment analysis (positive/negative/neutral distribution)
|
||||
- Audience interaction patterns
|
||||
- Content strengths and weaknesses
|
||||
- Missed opportunities
|
||||
|
||||
Provide a detailed structured summary covering all dimensions."""
|
||||
|
||||
CHUNK_PROMPTS = {
|
||||
ReportType.CONTENT: _CONTENT,
|
||||
ReportType.CONTENT_STATS: _CONTENT_STATS,
|
||||
ReportType.FULL_AUDIT: _FULL_AUDIT,
|
||||
}
|
||||
|
||||
|
||||
def build_chunk_prompt(
|
||||
report_type: ReportType,
|
||||
depth: Depth,
|
||||
focus_areas: list[FocusArea],
|
||||
lang: str,
|
||||
title: str,
|
||||
chunk_text: str,
|
||||
chunk_idx: int,
|
||||
|
|
@ -67,4 +28,14 @@ def build_chunk_prompt(
|
|||
total_chunks=total_chunks,
|
||||
chunk_text=chunk_text,
|
||||
)
|
||||
return base + "\n" + CHUNK_PROMPTS[report_type]
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue