New to Kestra?
Use blueprints to kickstart your first workflows.
Validates LLM-generated JSON payloads against strict Pydantic schemas, repairs minor syntax drift, and pauses for human review before database ingestion.
Orchestrates an automated quality assurance guardrail for generative AI applications by validating LLM-generated JSON responses against strict Pydantic schemas, automatically repairing common syntax drift, and halting pipelines with human-in-the-loop review before corrupted data enters downstream production databases.
Pause task.flowchart TD
A[inbound_llm_payload_webhook Trigger] --> B[validate_and_repair_schema Python Script]
B --> C[check_validation_gate Flowable If]
C -- Schema Invalid --> D[notify_slack_ai_drift Webhook]
D --> E[pause_for_human_review Pause]
C -- Schema Valid --> F[log_schema_validated Log]
E --> G[export_validation_manifest Return]
F --> G
inbound_llm_payload_webhook): Enables AI microservices to submit raw LLM responses for immediate validation.validate_and_repair_schema): Uses Pydantic to validate schemas, catch missing keys, and sanitize valid payloads.check_validation_gate): Evaluates operational safety boundaries using deterministic boolean branching.pause_for_human_review): Quarantines broken payloads for up to 12 hours, giving data stewards time to review.export_validation_manifest): Emits clean, sanitized JSON ready for relational database loading.Pause and Resume states without writing custom database review queues.| Name | Type | Default | Description |
|---|---|---|---|
llm_output_payload |
STRING |
(Sample invoice JSON) | Raw JSON string or markdown block returned by the LLM agent. |
target_schema_model |
SELECT |
InvoiceExtraction |
Target Pydantic schema contract to enforce. |
auto_repair_with_llm |
BOOL |
True |
Attempt automated normalization of trivial schema discrepancies. |
alert_on_drift |
BOOL |
True |
Toggle whether Slack webhook alerts are dispatched upon validation failure. |
{{ outputs.validate_and_repair_schema.vars.is_valid }}: Boolean flag indicating whether the payload conforms to the schema.{{ outputs.validate_and_repair_schema.vars.was_repaired }}: Boolean flag indicating whether automated normalization was applied.{{ outputs.validate_and_repair_schema.vars.validation_errors_count }}: Number of Pydantic validation constraint violations.{{ outputs.validate_and_repair_schema.vars.error_summary }}: Text summary of the validation error path and failure reason.{{ outputs.validate_and_repair_schema.vars.sanitized_payload }}: Fully validated, clean JSON string ready for downstream tasks.SLACK_WEBHOOK_URL.AI_GATE_WEBHOOK_KEY.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint for team alerts.AI_GATE_WEBHOOK_KEY: Secret authentication key for the inbound webhook trigger.SLACK_WEBHOOK_URL in your Kestra namespace secrets.company.ai namespace.US_DOLLAR -> USD).json ... ; ensure parsing scripts strip backticks before loading.Optional[T] = None to avoid false-positive validation errors.Decimal to avoid floating-point rounding discrepancies.io.kestra.plugin.jdbc.postgresql.Queries task to automatically insert the sanitized JSON into production tables upon validation clearance.