airflow.providers.common.ai.batch.dispatch¶
Dispatch from a connection and a model_id to a BatchAdapter.
The model_id prefix ("openai" in "openai:gpt-5") selects the adapter,
because the prefix decides the request shape and the batch API being called.
The connection type is then checked against the adapter’s
conn_types, since
the adapter has to know how to turn that connection’s fields into credentials.
This is a separate decision from
infer_model()
(the synchronous Agent path), which has no notion of “does this provider
have a batch API”.
Adapters are imported lazily, only once a request is dispatched to them, so
importing this module never requires openai/anthropic to be installed.
Another package can add an adapter in two ways: call register_adapter()
at import time, or declare an entry point in the
airflow.providers.common.ai.batch_adapters group whose name is the model
prefix and whose value is module:Class.
Attributes¶
Functions¶
|
Register an adapter class for its own |
|
Return the adapter class for an already-resolved adapter name. |
|
Split |
|
Resolve a connection type and |
|
Return the adapter name for a connection/model pair. See |
|
Instantiate an already-resolved adapter from a fetched connection. |
|
Fetch |
Module Contents¶
- airflow.providers.common.ai.batch.dispatch.ENTRY_POINT_GROUP = 'airflow.providers.common.ai.batch_adapters'[source]¶
- airflow.providers.common.ai.batch.dispatch.register_adapter(adapter_cls)[source]¶
Register an adapter class for its own
nameprefix.Intended for other provider packages that ship a batch engine (Bedrock, Vertex, Azure OpenAI). A registration overrides a built-in or entry-point adapter with the same prefix.
- airflow.providers.common.ai.batch.dispatch.import_adapter_class(name)[source]¶
Return the adapter class for an already-resolved adapter name.
- airflow.providers.common.ai.batch.dispatch.split_model_id(model_id)[source]¶
Split
"<provider>:<model>"into its two parts, rejecting a missing or empty half.- Raises:
UnsupportedBatchProviderError –
model_idisNone, has no":", or has an empty prefix or model name.
- airflow.providers.common.ai.batch.dispatch.get_adapter_class(conn_type, model_id)[source]¶
Resolve a connection type and
model_idto an adapter class.- Raises:
UnsupportedBatchProviderError – no adapter serves the
model_idprefix, ormodel_idis malformed.BatchProviderNotYetSupportedError – an adapter exists but does not accept this connection type (e.g.
pydanticai_azuretoday).
- airflow.providers.common.ai.batch.dispatch.resolve_adapter_name(conn_type, model_id)[source]¶
Return the adapter name for a connection/model pair. See
get_adapter_class().
- airflow.providers.common.ai.batch.dispatch.build_adapter_from_connection(name, conn)[source]¶
Instantiate an already-resolved adapter from a fetched connection.
Uses the connection’s
password/hostfields asapi_key/base_url, the same fieldsPydanticAIHookreads for the synchronous@task.llmpath.