airflow.providers.common.ai.mixins.approval¶
Attributes¶
Classes¶
Protocol for defer for approval mixin. |
|
Mixin that pauses an operator for human review before returning output. |
Module Contents¶
- class airflow.providers.common.ai.mixins.approval.DeferForApprovalProtocol[source]¶
Bases:
ProtocolProtocol for defer for approval mixin.
- approval_timeout: datetime.timedelta | None[source]¶
- class airflow.providers.common.ai.mixins.approval.LLMApprovalMixin[source]¶
Mixin that pauses an operator for human review before returning output.
When
require_approval=Trueon the operator, the generated output is presented to a human reviewer via the Airflow Human-in-the-Loop (HITL) interface. The task defers until the reviewer approves or rejects.If
allow_modifications=True, the reviewer can also edit the output before approving. The (possibly modified) output is then returned as the task result.Operators that use this mixin must set the following attributes:
require_approval(bool)allow_modifications(bool)approval_timeout(timedelta | None)prompt(str)
- defer_for_approval(context, output, *, subject=None, body=None)[source]¶
Write HITL detail, then defer to HITLTrigger for human review.
- Parameters:
context (airflow.sdk.Context) – Airflow task context.
output (Any) – The generated output to present for review.
subject (str | None) – Headline shown on the Required Actions page. Defaults to
"Review output for task `<task_id>`".body (str | None) – Markdown body shown below the headline. Defaults to the prompt and output wrapped in a code block.
- execute_complete(context, generated_output, event)[source]¶
Resume after human review.
Called automatically by Airflow when the HITL trigger fires. Returns the original or reviewer-modified output on approval.
- Parameters:
context (airflow.sdk.Context) – Airflow task context.
generated_output (str) – The output that was deferred for review.
event (dict[str, Any]) – Trigger event payload containing
chosen_options,params_input, andresponded_by_user.
- Raises:
HITLRejectException – If the reviewer rejected the output.
HITLTriggerEventError – If the trigger reported an error.
HITLTimeoutError – If the approval timed out.