Skip to content

Prompt Template Entity

Last Updated: 2026-03-09 Version: 1.0

PromptTemplate entities store the specific instructions sent to GPT-4. They are the "secret sauce" that ensures summaries are relevant to the intended audience.

📝 Core Purpose

  • Instruction Storage: Stores the system and user prompts used during generation.
  • Variable Support: Uses Handlebars-style placeholders such as {{title}} and {{content}} for dynamic data injection.
  • Inheritance Chain: Supports a hierarchy where a category-specific template can override a global role template.

🏗️ Data Architecture

Properties

  • TemplateText: The raw prompt string.
  • Role: The audience this template targets.
  • Category (Optional): If set, this template only applies to knowledge within this category.
  • Version: Tracks changes to the prompt over time.

Relationships

  • Role: ManyToOne (Required).
  • Category: ManyToOne (Optional).

⚖️ Business Logic

Resolution Hierarchy

The PromptBuilder uses the following logic to find the best template:

  1. Search for a template with matching Role AND Category.
  2. If not found, search for a template with matching Role where Category is NULL (Global Role Template).
  3. If still not found, fallback to a hardcoded system default.

Variable Injection

The entity doesn't just store text; it defines which variables it expects. Common variables include:

  • title: The title of the knowledge item.
  • content: The body text or scraped content.
  • role_name: The name of the target audience.

Technical Details

  • Location: src/Entity/PromptTemplate.php
  • Repository: src/Repository/PromptTemplateRepository.php

WARNING

Changing a template does NOT automatically regenerate existing summaries. It only affects future generations or manual "Regenerate" requests.