PhariaAssistant Generation template configuration

You can fully customise the templates shown to users in the Generation application. The template system uses three main JSON files:

  1. service/templates/templates.json - Defines the template structures, fields, and UI configuration.

  2. service/templates/template_prompts.json - Contains the prompt text used to generate content with the LLM for each language.

  3. ui/src/locales/template.json - Contains the UI text (such as labels, captions, placeholders) shown to users in each language.


templates.json structure

interface TemplatesFile {
  templates: Template\[\];
}

interface Template {
  id: string;                    // Unique identifier for the template
  name_key: string;              // Localization key for template name
  main\_prompt\_key: string;       // Reference to the main prompt in template_prompts.json
  fields: TemplateField\[\];       // Array of fields for this template
}

interface TemplateField {
  id: string;                    // Unique identifier for the field
  caption_key: string;           // Localization key for field caption/label
  type: "text\_input" | "text\_area" | "select";  // Field type
  placeholder_key: string;       // Localization key for placeholder text
  required?: boolean;            // Whether the field is required
  max_length?: number;           // Maximum character length (if applicable)
  options?: SelectOption\[\];      // Options for select fields
  prompt\_text\_key?: string;      // Reference to text in template_prompts.json
}

interface SelectOption {
  caption_key: string;           // Localization key for option display text
  value: string;                 // Value to be stored when option is selected
  prompt\_text\_key: string;       // Reference to text in template_prompts.json
  default?: boolean               // Set to true to preselect this option
}

templates.json example

{
  "templates": [
    {
      "id": "press_release",
      "name_key": "TEMPLATES.PRESS_RELEASE.NAME",
      "main_prompt_key": "PROMPTS.PRESS_RELEASE.MAIN_PROMPT",
      "fields": [
        {
          "id": "key_message",
          "caption_key": "TEMPLATES.PRESS_RELEASE.KEY_MESSAGE.CAPTION",
          "type": "text_area",
          "placeholder_key": "TEMPLATES.PRESS_RELEASE.KEY_MESSAGE.PLACEHOLDER",
          "required": true,
          "max_length": 5000,
          "prompt_text_key": "PROMPTS.PRESS_RELEASE.KEY_MESSAGE"
        },
        {
          "id": "primary_recipient",
          "caption_key": "TEMPLATES.PRESS_RELEASE.PRIMARY_RECIPIENT.CAPTION",
          "type": "select",
          "placeholder_key": "TEMPLATES.PRESS_RELEASE.PRIMARY_RECIPIENT.PLACEHOLDER",
          "required": true,
          "options": [
            {
              "caption_key": "TEMPLATES.PRESS_RELEASE.PRIMARY_RECIPIENT.OPTIONS.CITIZENS",
              "value": "citizens",
              "prompt_text_key": "PROMPTS.PRESS_RELEASE.PRIMARY_RECIPIENT.CITIZENS",
              "default": true
            },
            // More options...
          ]
        },
        // More fields...
      ]
    },
    // More templates...
  ]
}

template_prompts.json structure

interface TemplatePromptsFile {
  [languageCode: string]: {
    // Language code (e.g., "en", "de")
    PROMPTS: {
      [templateCategory: string]: {
        // e.g., "PRESS_RELEASE", "JOB_AD"
        MAIN_PROMPT: string; // Main prompt template with placeholders
        [fieldCategory: string]: {
          // Categories for different fields
          [optionKey: string]: string; // Actual text for options
        };
      };
    };
  };
}

template_prompts.json example

{
  "en": {
    "PROMPTS": {
      "PRESS_RELEASE": {
        "MAIN_PROMPT": "Create a press release about {{key_message}}. Target audience is {{primary_recipient}}. Use a {{tone_of_voice}} tone. Reference previous release: {{previous_release}}. Include legal basis: {{legal_basis}}.",
        "PRIMARY_RECIPIENT": {
          "CITIZENS": "the general public",
          "BUSINESSES": "businesses and organizations",
          "PUBLIC_SERVANTS": "government employees and public servants"
        },
        "PREVIOUS_RELEASE": {
          "PR24": "our previous press release on skilled worker shortages (PR24)",
          "PR18": "our previous announcement on digital transformation initiatives (PR18)",
          "NONE": "no specific previous release"
        },
        "KEY_MESSAGE": "It's about the following text: {{value}}."
        // More fields...
      },
      // More templates...
    }
  },
  "de": {
    "PROMPTS": {
      "PRESS_RELEASE": {
        "MAIN_PROMPT": "Erstellen Sie eine Pressemitteilung über {{key_message}}. Die Zielgruppe ist {{primary_recipient}}. Verwenden Sie einen {{tone_of_voice}} Ton. Referenzieren Sie die vorherige Veröffentlichung: {{previous_release}}. Beziehen Sie die Rechtsgrundlage ein: {{legal_basis}}.",
        "PRIMARY_RECIPIENT": {
          "CITIZENS": "die allgemeine Öffentlichkeit",
          "BUSINESSES": "Unternehmen und Organisationen",
          "PUBLIC_SERVANTS": "Mitarbeiter im öffentlichen Dienst"
        },
        "KEY_MESSAGE": "Es geht um folgenden Text: {{value}}."
        // More fields...
      },
      // More templates...
    }
  }
}

template.json example

{
  "en": {
    "TEMPLATES": {
      "PRESS_RELEASE": {
        "NAME": "Press Release",
        "KEY_MESSAGE": {
          "CAPTION": "Key message input",
          "PLACEHOLDER": "Enter the main message of your press release"
        },
        "PRIMARY_RECIPIENT": {
          "CAPTION": "Primary recipient group",
          "PLACEHOLDER": "Select the primary audience",
          "OPTIONS": {
            "CITIZENS": "Citizens",
            "BUSINESSES": "Businesses",
            "PUBLIC_SERVANTS": "Public Servants"
          }
        }
      }
    }
  }
}