AI Summary & Template System
Last Updated: 2026-03-09 Version: 2.0 (Consolidated)
The AI Summary system is a core feature of the Yappa Knowledge Hub, responsible for generating tailored, Dutch-language summaries for different target audiences (Roles). It uses a sophisticated Template Hierarchy to ensure that summaries are relevant to the specific context of the knowledge item.
🏛️ System Architecture
The system is decoupled into specialized services, ensuring that prompt logic, AI orchestration, and data persistence are handled separately.
Core Components
- AiSummaryService: The master orchestrator for creating, editing, and regenerating summaries.
- PromptBuilder: Resolves the correct template and injects dynamic variables (Title, Content, URL, etc.).
- RoleManager: Manages the audiences (e.g., Developers, Sales, CEO) and their specific needs.
- OpenAI Provider: Handles the low-level API communication with GPT-4.
📝 The Template System
The system uses a Hierarchical Resolution strategy to find the most specific prompt for any given situation.
1. Template Hierarchy
When a summary is requested, the system searches in this order:
- Custom Template: Provided at runtime (e.g., for one-off manual regeneration).
- Category-Specific Template: A template tailored for both a Role AND a specific Thematic List (e.g., Developers in Backend).
- Global Template: The default template for a Role (e.g., Developers - Global).
2. Prompt Construction
The PromptBuilder injects real-time data into templates using Handlebars-style syntax:
{{title}}: The item's primary title.{{content}}: The core text or scraped URL content.{{role_name}}: The audience name to set the AI's persona.{{#if url}}...{{/if}}: Conditional blocks for optional data.
🔄 Lifecycle: Generation & Editing
Data Flow
- Trigger: A user adds knowledge or requests a summary in Slack.
- Resolution:
PromptBuildercreates a Dutch prompt based on the hierarchy. - Generation: GPT-4 generates the Dutch summary.
- Persistence: The summary is saved as a versioned entity and optionally synced back to Notion.
Versioning & Manual Edits
The system treats AI as a "co-author."
- Every regeneration creates a new version (v1, v2, etc.).
- Users can manually edit the summary. Manual edits are tracked and prevent the AI from overwriting preferred human wording unless explicitly requested.
📊 Monitoring & Cost
Every generated summary tracks metadata for transparency:
- Model: (e.g., GPT-4o)
- Token Count: Prompt vs. Completion.
- Cost: Real-time EUR calculation.
- Quality: Can be rated by users to improve templates over time.
Related Documentation
- Entities Guide (See
AiSummaryandRolemodels) - Notion Integration
- Slack Bot Handlers