Skip to content

AI Summary System

Last Updated: 2026-05-27

The AI Summary system generates concise Dutch-language summaries for knowledge items, powering the digest pipeline.

Architecture

The system is intentionally simple — a single prompt, a single provider interface, and lazy generation.


How It Works

Lazy Generation

AI summaries are generated only when needed — during digest creation. If a knowledge item already has a highlight, the AI call is skipped entirely.

The Prompt

A single hardcoded constant in DigestConstants::HIGHLIGHT_SUMMARY_PROMPT:

Summarize the following content in 2-3 sentences (in Dutch).
If it's a link or short title, infer its context from the extracted text:

Title/Input: %s
URL: %s

Content:
%s

Three variables are injected via sprintf: title, URL, and content.

AI Configuration

ParameterValue
Temperature0.3 (factual, consistent)
Max Tokens150 (2-3 sentences)
LanguageDutch (implicit in prompt)
FallbackTruncate content to 200 characters on failure

Provider Architecture

The AiProviderInterface abstracts AI provider communication:

php
interface AiProviderInterface {
    public function generateCompletion(string $prompt, AiOptionsDto $options): AiResponseDto;
}

OpenAIService implements this with dual support:

  • OpenAI — Default when OPENAI_API_URL points to api.openai.com
  • OpenRouter — Auto-detected when URL contains openrouter.ai

Switching providers requires only changing environment variables.


Storage

AI summaries are stored in two locations:

  1. Knowledge.highlight — The primary TEXT field. The 2-3 sentence Dutch summary persisted on the knowledge entity.

  2. Digest.knowledgeHighlights — A JSON snapshot captured at digest generation time. Each entry includes {id, title, highlight, aiSummary, notionUrl, tags, createdAt}. This makes digests immutable — even if source knowledge changes later.