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
| Attribute | Type | Description | Example |
|---|---|---|---|
use | TEXT | Identifiziert welche Komponente erstellt werden soll. Format: plugin-name:ComponentName | "base:FetchTicketsPipe" |
injects | name:value pairs | Maps Constructor-Parameter-Namen zu Service IDs, verbindet Dependencies zu dieser Komponente | { ticket_system: "otobo_znuny" } |
params | name:value pairs | Konfigurationsparameter 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
servicesAbschnitt - Wiederverwendbar über mehrere Pipes
- Muss ein
idFeld 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
idFeld um Ergebnisse zu referenzieren - Nutzen Services via
injectsum 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.
| Path | Type | Description | Example | |
|---|---|---|---|---|
otai | OpenTicketAIConfig | Main application config root. | ||
otai.api_version | str | API version for compatibility. | "1" | |
otai.plugins[] | list[str] | Python module paths of plugins to load. | "otai_hf_local" | |
otai.infrastructure | InfrastructureConfig | Infra-level settings. | ||
otai.infrastructure.logging | LoggingConfig | Logging configuration. | ||
otai.infrastructure.logging.level | str | Min log level. | "INFO" | |
otai.infrastructure.logging.log_to_file | bool | Enable file logging. | false | |
otai.infrastructure.logging.log_file_path | `str | None` | Log file path when enabled. | "/var/log/app.log" |
otai.infrastructure.logging.log_format | str | Python logging format string. | "%(asctime)s - %(levelname)s - %(message)s" | |
otai.infrastructure.logging.date_format | str | Date format for logs. | "%Y-%m-%d %H:%M:%S" | |
otai.services | dict[str, InjectableConfigBase] | Map of service-id → DI config. | ||
otai.services.<id> | InjectableConfigBase | One service definition. | ||
otai.services.<id>.use | str | Python class path to instantiate. | "pkg.mod.Class" | |
otai.services.<id>.injects | dict[str,str] | DI bindings: ctor-param → service-id. | { "db": "ticket-db" } | |
otai.services.<id>.params | dict[str,Any] | Constructor params (templating allowed). | { "url": "{{ get_env('DB_URL') }}" } | |
otai.services.<id>.id | str | Optional explicit identifier (when using InjectableConfig). | "ticket-db" | |
otai.orchestrator | PipeConfig | Orchestrator pipeline root. | ||
otai.orchestrator.id | str | Pipe identifier (for referencing). (inherits) | "root" | |
otai.orchestrator.use | str | Python class path of the Pipe. (inherits) | "project.pipes.CompositePipe" | |
otai.orchestrator.injects | dict[str,str] | DI to sub-pipes/services. (inherits) | { "step1": "ticket-db" } | |
otai.orchestrator.params | dict[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)
| Function | Parameters | Returns | Errors if… |
|---|---|---|---|
at_path | value: Any, path: text | Nested value at "a.b.c" path; supports dicts + Pydantic models | Invalid path format |
has_failed | pipe_id: text | True if the given pipe result is marked failed | Unknown pipe ID |
get_pipe_result | pipe_id: text, data_key: text;default = "value" | Value stored in previous pipe result under given data_key | Pipe or key missing |
get_parent_param | param_key: text | Inherited parent parameter value | Parent missing or key missing |
get_env | name: text | Value of environment variable | Env 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
