airflow.providers.common.ai.policies.decision¶
The decision policy an LLM operator applies to the model’s answer, and the branch options it chooses from.
DecisionPolicy says when the operator may act on the answer by itself and what happens when it
may not. BranchOption describes one branch of LLMBranchOperator
and lets it demand a different confidence than the policy’s. Both are plain configuration: the operator
keeps them as attributes and builds the model-facing types at run time.
Attributes¶
Classes¶
When an LLM operator may act on the model's answer by itself, and what happens when it may not. |
|
One branch the model may pick: what choosing it means, and the confidence it needs. |
Functions¶
|
Validate one confidence bar: a number from 0 to 1, returned as a float. |
Module Contents¶
- airflow.providers.common.ai.policies.decision.UNCERTAIN_ACTIONS: tuple[UncertainAction, ...] = ('review', 'fail')[source]¶
- airflow.providers.common.ai.policies.decision.check_bar(value, label)[source]¶
Validate one confidence bar: a number from 0 to 1, returned as a float.
- class airflow.providers.common.ai.policies.decision.DecisionPolicy[source]¶
When an LLM operator may act on the model’s answer by itself, and what happens when it may not.
- Parameters:
min_confidence – The confidence, from 0 to 1, the answer needs for the operator to act without a person.
None(default) is no gate: the operator behaves as it always has. Confidence comes from models that report one, such as a classifier model (TypeSafe’s), inprovider_details. A model that reports none counts as under the bar, so swapping the connection to a text model does not silently switch off a control the author set.on_uncertain – What happens under the bar.
"review"(default) sends the answer to human review through the same approval flow asrequire_approval, which needs Airflow 3.1+;"fail"fails the task withLowConfidenceError. Inert withoutmin_confidence.require_approval=Trueon the operator always wins and asks a person whatever the confidence.
- class airflow.providers.common.ai.policies.decision.BranchOption[source]¶
One branch the model may pick: what choosing it means, and the confidence it needs.
The value of
LLMBranchOperator’sbranchesmapping, keyed by downstream task ID. A bare string in that mapping is shorthand forBranchOption(description=...).- Parameters:
description – What selecting this branch means: its scope and its boundary cases. Sent to the model in the output schema next to the option, so the model reads the option together with its meaning rather than guessing from the task ID. Supports Jinja templating.
Nonepresents the branch by its task ID alone.min_confidence – A bar for this branch that differs from the
DecisionPolicy’s, so a branch whose wrong pick costs more can demand more certainty. Needs a policy bar to differ from;Noneinherits it.
- template_fields: ClassVar[collections.abc.Sequence[str]] = ('description',)[source]¶