Konfiguration & Template Rendering

Verstehen Sie den Konfigurationslebenszyklus von Open Ticket AI, Template Rendering mit Jinja2, Dependency Injection und wie YAML in Runtime-Objekte transformiert wird.

Konfiguration & Template Rendering

Open Ticket AI ermöglicht Ihnen die Erstellung dynamischer Konfigurationen mit YAML plus Jinja2 Template Expressions wie

{{ ... }} ohne Leerzeichen

Dies ermöglicht Ihnen die Wiederverwendung von Werte, das Lesen von Environment-Variablen und die Referenzierung von Ergebnisse aus anderen Pipes — alles während die Konfiguration sauber und deklarativ bleibt.

Key Concepts

Injectable Configuration Structure

Sowohl Services als auch Pipes in Open Ticket AI verwenden die gleiche Konfigurationsstruktur genannt InjectableConfig. Das Verständnis dieser drei Kernattribute hilft Ihnen, jede Komponente im System zu konfigurieren.

Configuration Attributes

AttributeTypeDescriptionExample
useTEXTIdentifiziert welche Komponente erstellt werden soll. Format: plugin-name:ComponentName"base:FetchTicketsPipe"
injectsname:value pairsMaps Constructor-Parameter-Namen zu Service IDs, verbindet Dependencies zu dieser Komponente{ ticket_system: "otobo_znuny" }
paramsname:value pairsKonfigurationsparameter spezifisch für diese Komponente. Jede Komponente-Typ erwartet unterschiedliche Parameter{ limit: 25, queue: "Support" }

Key Differences: Services vs. Pipes

Obwohl beide InjectableConfig verwenden, unterscheiden sie sich in der Nutzung:

Services

  • Einmal definiert im services Abschnitt
  • Wiederverwendbar über mehrere Pipes
  • Muss ein id Feld für Referenzierung haben
  • Repräsentieren meist externe Systeme

Example:

services:
  otobo_znuny:
    use: 'otobo-znuny:OTOBOZnunyTicketSystemService'
    injects: {}
    params:
      base_url: 'https://helpdesk.example.com'
      password: "{{ get_env('OTOBO_PASSWORD') }}"

Pipes

  • Definiert innerhalb Pipeline steps
  • Führen Aktionen in Sequenz aus
  • Haben ebenfalls ein id Feld um Ergebnisse zu referenzieren
  • Nutzen Services via injects um Arbeit zu erledigen

Example:

steps:
  - id: fetch_tickets
    use: 'base:FetchTicketsPipe'
    injects:
      ticket_system: 'otobo_znuny'
    params:
      ticket_search_criteria:
        limit: 25

Template Rendering

Alle params und injects Werte unterstützen Jinja2 Templating für dynamische Konfiguration:

params:
  api_key: "{{ get_env('API_KEY') }}"
  queue: "{{ get_pipe_result('classify', 'label') }}"

Related: Template Rendering · Dependency Injection

Config Reference

Hier ist die Markdown-Tabelle, die die vollständige Konfigurationsstruktur beschreibt, sauber und bereit für Ihre Docs.

PathTypeDescriptionExample
otaiOpenTicketAIConfigMain application config root.
otai.api_versionstrAPI version for compatibility."1"
otai.plugins[]list[str]Python module paths of plugins to load."otai_hf_local"
otai.infrastructureInfrastructureConfigInfra-level settings.
otai.infrastructure.loggingLoggingConfigLogging configuration.
otai.infrastructure.logging.levelstrMin log level."INFO"
otai.infrastructure.logging.log_to_fileboolEnable file logging.false
otai.infrastructure.logging.log_file_path`strNone`Log file path when enabled."/var/log/app.log"
otai.infrastructure.logging.log_formatstrPython logging format string."%(asctime)s - %(levelname)s - %(message)s"
otai.infrastructure.logging.date_formatstrDate format for logs."%Y-%m-%d %H:%M:%S"
otai.servicesdict[str, InjectableConfigBase]Map of service-id → DI config.
otai.services.<id>InjectableConfigBaseOne service definition.
otai.services.<id>.usestrPython class path to instantiate."pkg.mod.Class"
otai.services.<id>.injectsdict[str,str]DI bindings: ctor-param → service-id.{ "db": "ticket-db" }
otai.services.<id>.paramsdict[str,Any]Constructor params (templating allowed).{ "url": "{{ get_env('DB_URL') }}" }
otai.services.<id>.idstrOptional explicit identifier (when using InjectableConfig)."ticket-db"
otai.orchestratorPipeConfigOrchestrator pipeline root.
otai.orchestrator.idstrPipe identifier (for referencing). (inherits)"root"
otai.orchestrator.usestrPython class path of the Pipe. (inherits)"project.pipes.CompositePipe"
otai.orchestrator.injectsdict[str,str]DI to sub-pipes/services. (inherits){ "step1": "ticket-db" }
otai.orchestrator.paramsdict[str,Any]Pipe parameters (templating allowed). (inherits){}

Tiny example

otai:
  api_version: '1'
  plugins: []
  infrastructure:
    logging:
      level: 'INFO'
  services:
    ticket-db:
      use: 'plugin_name:Database'
      params:
        url: "{{ get_env('DB_URL') }}"
  orchestrator:
    id: 'root'
    use: 'base:CompositePipe'
    injects:
      step1: 'ticket-db'
    params: {}

Available helper functions (for config.yml templates)

FunctionParametersReturnsErrors if…
at_pathvalue: Any, path: textNested value at "a.b.c" path; supports dicts + Pydantic modelsInvalid path format
has_failedpipe_id: textTrue if the given pipe result is marked failedUnknown pipe ID
get_pipe_resultpipe_id: text, data_key: text;default = "value"Value stored in previous pipe result under given data_keyPipe or key missing
get_parent_paramparam_key: textInherited parent parameter valueParent missing or key missing
get_envname: textValue of environment variableEnv var missing
fail(none)A “FailMarker” sentinel object to signal explicit failure paths

Usage examples in config.yml

Read an environment variable

api:
  token: "{{ get_env('API_TOKEN') }}"
  baseUrl: 'https://api.example.com'

Consume a previous pipe’s result

classification:
  label: "{{ get_pipe_result('classify_ticket', 'label') }}"
  confidence: "{{ get_pipe_result('classify_ticket', 'score') }}"
  isLowConfidence: "{{ get_pipe_result('classify_ticket', 'score') < 0.6 }}"

Check if a pipe failed

shouldRetry: "{{ has_failed('fetch_customer') }}"

Read a parent parameter

timeoutMs: "{{ get_parent_param('timeoutMs') }}"

Emit an explicit failure marker

result: '{{ fail() }}'

Access nested data (dict or Pydantic model)

userCity: "{{ at_path(user, 'address.city') }}"

Full Examples / Templates

See full working examples of config.yml

Config Examples.