id stringlengths 15 25 | source stringclasses 1
value | chunk_index int64 0 393k | token_count int32 449 512 | content stringlengths 203 7.95k |
|---|---|---|---|---|
combine_chunk_500 | combine.txt | 500 | 512 | , calls tools (database queries, API calls, etc.) in
a multi-turn loop, and returns a final answer.
This is different from
:class:`~airflow.providers.common.ai.operators.llm.LLMOperator`, which sends
a single prompt and returns the output. ``AgentOperator`` manages a stateful
tool-call loop where the LLM decides which... |
combine_chunk_501 | combine.txt | 501 | 512 | also return a ``Sequence[UserContent]`` -- for
example, a list mixing strings with ``ImageUrl``, ``BinaryContent``, or other
pydantic-ai user-content types -- to send vision, audio, or document inputs
to the model. This mirrors the input types accepted by pydantic-ai's
``Agent.run_sync``.
.. code-block:: python
... |
combine_chunk_502 | combine.txt | 502 | 512 | prompt
---------------------
``system_prompt`` is a templated field, so instead of a static string it
can be a Jinja expression that reads a value an earlier task already
computed -- for example, tailoring the agent's instructions to a
classification produced upstream.
.. exampleinclude:: /../../ai/src/airflow/provi... |
combine_chunk_503 | combine.txt | 503 | 512 | every task that uses the definition group under one agent.
To keep the definition out of Python, for example to share it with a program that
does not run on Airflow, write a pydantic-ai
`agent spec <https://pydantic.dev/docs/ai/core-concepts/agent-spec/>`__ file and pass its path through
``agent_params``. A model set... |
combine_chunk_504 | combine.txt | 504 | 512 |
^^^^^^^^^^^^^^^^^
Moved to :doc:`../durable_execution`.
.. _agent-prompt-caching:
Prompt caching
^^^^^^^^^^^^^^
Every request an agent makes re-sends its tool definitions, its system prompt and the
conversation so far. An agent that calls three tools makes four requests, and a mapped
``@task.agent`` makes that man... |
combine_chunk_505 | combine.txt | 505 | 512 | reads. When the last tool returns much more than the
system prompt and tool definitions add up to, as a query returning thousands of rows can,
that final write costs more than the earlier reads saved.
- **Map indexes that start together.** A cache entry exists only once the response that wrote
it has started, so... |
combine_chunk_506 | combine.txt | 506 | 512 | to the agent (operator) or the return value
of the decorated function (decorator).
- ``llm_conn_id``: Airflow connection ID for the LLM provider.
- ``model_id``: Model identifier (e.g. ``"openai:gpt-5"``). Overrides the
connection's extra field.
- ``system_prompt``: System-level instructions for the agent. Support... |
combine_chunk_507 | combine.txt | 507 | 512 | -- agents are particularly prone to runaway tool loops,
so ``tool_calls_limit`` is a useful guardrail. It also supports a
USD ``cost_limit``; see :ref:`howto/operator:llm` for the caveats (not a
hard guarantee; not enforced for models pydantic-ai can't price, which log
a warning instead of failing the run) and... |
combine_chunk_508 | combine.txt | 508 | 512 | regeneration starts a fresh count.
- ``durable``: When ``True``, records each step the agent completes (model
requests, tool calls, other capabilities' ``@durable_operation`` methods) in a
journal kept for the task instance, and replays the recorded steps on retry
instead of running them again. A pydantic-ai ``... |
combine_chunk_509 | combine.txt | 509 | 512 | See :doc:`../message_history`.
- ``emit_message_history``: Push the post-run transcript to XCom under the key
``message_history``. Defaults to ``True`` when ``message_history`` is set and ``False``
otherwise; ``True`` records a single-turn run without seeding it. See :doc:`../message_history`.
- ``serialize_output... |
combine_chunk_510 | combine.txt | 510 | 512 | DEBUG level, the LLM output is also logged (truncated to 500 characters).
Both layers use Airflow's ``::group::`` / ``::endgroup::`` log markers, which
render as collapsible sections in the Airflow UI task log viewer.
To disable real-time tool logging while keeping the post-run summary:
.. code-block:: python
... |
combine_chunk_511 | combine.txt | 511 | 512 | changelog <index>`.
.. airflow-providers-commits::
<|file|>airflow/providers/common/ai/docs/approval_gates.rst
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyri... |
combine_chunk_512 | combine.txt | 512 | 512 | start-after: [START howto_operator_llm_approval_walkthrough]
:end-before: [END howto_operator_llm_approval_walkthrough]
The Dag runs as-is once the ``pydanticai_default`` connection points at a model; see
:doc:`connections/pydantic_ai`.
Where the review appears
------------------------
Once the model has answere... |
combine_chunk_513 | combine.txt | 513 | 512 |
---------------------
Each row comes from a run of the Dag above, answered by the user ``admin``, against a
stand-in model that always returns the same sentence; your model's wording will differ.
The timeout rows set ``approval_timeout=timedelta(minutes=1)`` and the
``on_approval_timeout`` value shown. An exception a... |
combine_chunk_514 | combine.txt | 514 | 512 | ``return_value`` XCom, which is what ``draft.output``
passes to ``publish``.
A rejection, or a timeout with ``"fail"`` or ``"reject"``, fails the task like any other
exception, so ``retries`` apply: with a retry left, the task goes to ``up_for_retry``, and
the retry calls the model again and opens the review again, u... |
combine_chunk_515 | combine.txt | 515 | 512 | with ``retries`` set the
next try runs the model again and the rejected edit is not carried over.
With ``output_type=str`` any edit is accepted as is, and so is an edit to a union with a ``str``
member, such as ``Model | str``, which keeps the text when it does not validate as the model.
An output function, a pydanti... |
combine_chunk_516 | combine.txt | 516 | 512 | l.HITLOperator` does with
``notifiers``. The notifiers run once the review is open and can reference
the review ``{{ task.subject }}`` and ``{{ task.body }}`` in their templates,
as the example under `Timeouts`_ does: its notifier writes the subject and body to the
task log, just before ``Pausing task as AWAITING_INPU... |
combine_chunk_517 | combine.txt | 517 | 512 | 1.6 only
``id`` is compared. On Airflow 3.4 and later a cleared or retried task replaces the
list along with the rest of the review. On Airflow 3.1 to 3.3 the list is stored when the
review is first created, so if you edit ``approval_assigned_users`` and clear the task,
the old list still applies.
.. _approval-gates... |
combine_chunk_518 | combine.txt | 518 | 512 | name, the per-field ``confidence`` and ``probabilities`` (empty for a text
model), the bar that applied, why the output went to review if it did, who
decided, and the gate configuration in force.
A pending record is checkpointed with the paused task and finalized from that
copy on resume, not from the XCom. See :ref:`... |
combine_chunk_519 | combine.txt | 519 | 512 | _providers` lists every vendor):
.. code-block:: bash
pip install "apache-airflow-providers-common-ai[openai]"
2. Create the connection
------------------------
Model calls go through an Airflow connection of type ``pydanticai``. The connection holds
the API key and the model name in ``provider:model`` form, so... |
combine_chunk_520 | combine.txt | 520 | 512 | Dag once in the foreground from the machine where you saved the file:
.. code-block:: bash
airflow dags test quickstart_llm
The command parses the Dag, runs ``summarize`` and then ``publish``, and prints both task
logs to the terminal. You can also trigger the Dag from the UI with the play button on the
``quick... |
combine_chunk_521 | combine.txt | 521 | 512 | work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENS... |
combine_chunk_522 | combine.txt | 522 | 512 | ), which takes precedence over the list.
Guardrails
----------
A guardrail is a capability that checks what goes into or comes out of the agent and stops the
run when a check fails. This example uses ``InputGuard`` from ``pydantic-ai-shields`` to reject a
prompt before the agent run starts.
.. note::
Experiment... |
combine_chunk_523 | combine.txt | 523 | 512 |
* - Capability
- On retry
* - ``Thinking``, and ``WebSearch``, ``WebFetch`` or ``ImageGeneration`` when the model's
provider runs the tool natively
- Replayed with the recorded model response.
* - ``WebSearch``, ``WebFetch`` or ``ImageGeneration`` falling back to a local tool, for a
... |
combine_chunk_524 | combine.txt | 524 | 512 | /docs/recovery.rst
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (th... |
combine_chunk_525 | combine.txt | 525 | 512 | , as above. A step that was still running runs again.
* - Either of the last two, without ``durable=True``
- Airflow ``retries``
- Run again from the start: every model call is paid for again and every tool runs
again.
A response the provider does return but pydantic-ai rejects, such as a content-f... |
combine_chunk_526 | combine.txt | 526 | 512 | continues the run; a tool that
already ran is not called again. The next connection can be another vendor's model,
for example an Anthropic model taking over a run an OpenAI model started.
A streamed request is the exception. When the run streams, for example with an
``event_stream_handler`` in ``agent_params``, the ... |
combine_chunk_527 | combine.txt | 527 | 512 | the whole chain, whichever connection
answered. Adding, removing or reordering a connection in ``fallback_conn_ids``, or
changing the ``model`` of a connection in it, between attempts therefore makes the retry
run every step live, tools included. Changing a connection's credentials or host does
not. "How a retry repla... |
combine_chunk_528 | combine.txt | 528 | 512 | viders-from-sources.rst
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.... |
combine_chunk_529 | combine.txt | 529 | 512 | s and routes the spans through the OpenTelemetry exporter Airflow already
uses, so they appear in whatever backend your deployment runs (Jaeger, Tempo,
Grafana, Phoenix, Langfuse, an OTLP collector, ...), correlated to the task that
produced them.
This covers all of the LLM operators (:class:`~airflow.providers.common... |
combine_chunk_530 | combine.txt | 530 | 512 | the
context and starts a new trace.
* **Run join key.** For an ``AgentOperator`` run or a run of ``LLMOperator`` or one of
its subclasses (and their decorator equivalents), the task-instance id
(unique per attempt, since Airflow regenerates it on each retry) is passed to
pydantic-ai as the run's ``run_id``. It... |
combine_chunk_531 | combine.txt | 531 | 512 | `` above, so a downstream task, a Jinja template, or a REST client can read which
model responded without parsing the decision record or a span
(``ti.xcom_pull(task_ids="my_agent", key="__AIRFLOW__COMMON_AI_MODEL_NAME__")``).
``AgentOperator`` and ``LLMOperator`` and its subclasses (and their decorator forms)
p... |
combine_chunk_532 | combine.txt | 532 | 512 |
provider-reported billing. With a custom XCom backend that keeps large values in external
storage (e.g. ``common.io`` with ``xcom_objectstorage_threshold`` set low), the tab cannot
show those values: the public XCom endpoint it calls returns the reference the backend
stored in the database, since the API serve... |
combine_chunk_533 | combine.txt | 533 | 512 | model inputs and
outputs (``gen_ai.input.messages`` / ``gen_ai.output.messages``), set:
.. code-block:: ini
[common.ai]
capture_content = True
.. warning::
With ``capture_content`` enabled, prompts, completions, and tool arguments are
exported to your tracing backend **without redaction**. Airflow'... |
combine_chunk_534 | combine.txt | 534 | 512 | at module level; ADK reads
its switches when a ``TelemetryConfig`` is built, so build that inside the block too.
Every span started inside the block under the worker's tracer provider carries the same
``airflow.*`` identity attributes as ``AgentOperator``'s spans. When no tracer provider made
a span for the task, the... |
combine_chunk_535 | combine.txt | 535 | 512 | dantic AI agent you build yourself, or another framework through its adapter. It
answers which toolsets are used and from where without reading task logs. The counter
carries three tags:
.. list-table::
:header-rows: 1
:widths: 20 80
* - Tag
- Values
* - ``toolset``
- The toolset class, such as ... |
combine_chunk_536 | combine.txt | 536 | 512 | 2.0
.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
und... |
combine_chunk_537 | combine.txt | 537 | 512 | , and the extra and model prefix each one needs, is on
:doc:`../model_providers`. Vendor outages can fail over to a second connection with
:doc:`../provider_fallback`. Error messages from a misconfigured connection are listed
with their fixes in :doc:`../troubleshooting`.
<|file|>airflow/providers/common/ai/docs/conne... |
combine_chunk_538 | combine.txt | 538 | 512 | uses ``pydanticai_bedrock_default`` by default.
Configuring the Connection
--------------------------
All fields below are ``extra`` (JSON) fields.
Model
Bedrock model identifier (e.g. ``bedrock:us.anthropic.claude-opus-4-5``).
A bare name is automatically resolved to ``bedrock:<name>`` -- Bedrock is this
... |
combine_chunk_539 | combine.txt | 539 | 512 | ``api_key``, mapped to ``AWS_BEARER_TOKEN_BEDROCK``), used
first if set.
- IAM keys (``aws_access_key_id`` + ``aws_secret_access_key``, optionally
``aws_session_token``), used only when no bearer token is set.
- The environment-variable / instance-role credential chain
(``AWS_PROFILE``, IAM role, …) when none of ... |
combine_chunk_540 | combine.txt | 540 | 512 | specific language governing permissions and limitations
under the License.
.. _howto/connection:pydanticai:
Pydantic AI connection
======================
The `Pydantic AI <https://ai.pydantic.dev/>`__ connection type configures access
to LLM providers via the pydantic-ai framework. A single connection type work... |
combine_chunk_541 | combine.txt | 541 | 512 | 's API. Only needed for custom endpoints. For ``ollama:``
models it can instead come from the ``OLLAMA_BASE_URL`` environment variable;
``openai:`` models, including the Ollama example below that uses
``openai:llama3``, read ``OPENAI_BASE_URL`` instead:
- Ollama: ``http://localhost:11434/v1``
- vLL... |
combine_chunk_542 | combine.txt | 542 | 512 | `.
Examples
--------
.. _conn-example-openai:
OpenAI
^^^^^^
.. code-block:: json
{
"conn_type": "pydanticai",
"password": "sk-...",
"extra": "{\"model\": \"openai:gpt-5\"}"
}
.. _conn-example-anthropic:
Anthropic
^^^^^^^^^
.. code-block:: json
{
"conn_type": "pydanti... |
combine_chunk_543 | combine.txt | 543 | 512 | through the gateway.
.. _conn-example-bedrock:
AWS Bedrock
^^^^^^^^^^^
Leave password empty and configure ``AWS_PROFILE`` or IAM role in the environment:
.. code-block:: json
{
"conn_type": "pydanticai",
"extra": "{\"model\": \"bedrock:us.anthropic.claude-opus-4-6-v1:0\"}"
}
This still wo... |
combine_chunk_544 | combine.txt | 544 | 512 | model`` declared in the
spec file, when neither ``model_id`` nor the connection's ``model`` extra is set. A
connection that declares
``fallback_conn_ids`` but no model raises instead, because a spec-file model cannot
be wrapped in a fallback chain (see :doc:`/hooks/pydantic_ai`).
Whichever of sources 1-3 s... |
combine_chunk_545 | combine.txt | 545 | 512 | -compatible v1 API, ``api_version``. The generic
:doc:`pydantic_ai` connection instead supplies ``api_key`` and an optional
``base_url``.
.. note::
This connection type was previously named ``pydanticai-azure``. Connections
stored as a URI or as JSON keep working; a type stored verbatim, such as a row
cre... |
combine_chunk_546 | combine.txt | 546 | 512 | endpoint path does not end in ``/v1`` and the host is not
``*.models.ai.azure.com``. When required, it falls back to the
``OPENAI_API_VERSION`` environment variable if omitted. Endpoints matching
either OpenAI-compatible v1 form reject this field.
Fallback Connections
Other connection IDs to fail over... |
combine_chunk_547 | combine.txt | 547 | 512 | WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
.. _howto/connection:mcp:
MCP server connection
=====================
The MCP connection type configures access to
`MCP (Model Context Prot... |
combine_chunk_548 | combine.txt | 548 | 512 |
for ``http``/``sse``. Must be a non-negative finite number; ``0`` or ``null``
disables the timeout. Default: ``10``.
Examples: ``30``
Examples
--------
**HTTP transport (remote MCP server)**
.. code-block:: json
{
"conn_type": "mcp",
"host": "http://localhost:3001/mcp"
}
**SSE... |
combine_chunk_549 | combine.txt | 549 | 512 | _howto/connection:llamaindex:
LlamaIndex connection
=====================
.. note::
Experimental: this can change or be removed in a minor release of this provider.
See :ref:`howto/stability`.
The ``llamaindex`` connection type configures access to LLM and embedding
providers for `LlamaIndex <https://docs.... |
combine_chunk_550 | combine.txt | 550 | 512 | 's
``embed_model=`` / ``llm=`` parameter; :doc:`../hooks/llamaindex` explains the check
and shows the pattern.
Model resolution order
-----------------------
Both ``get_embedding_model()`` and ``get_llm()`` resolve the model
identifier from, in order:
1. The ``embed_model`` / ``llm_model`` constructor argument on
... |
combine_chunk_551 | combine.txt | 551 | 512 | Chain <https://python.langchain.com/>`__'s universal
``init_chat_model`` / ``init_embeddings`` entry points. It backs
:class:`~airflow.providers.common.ai.hooks.langchain.LangChainHook` (see
:doc:`../hooks/langchain` for hook usage and installation instructions).
Default Connection IDs
----------------------
The ``La... |
combine_chunk_552 | combine.txt | 552 | 512 | in order:
1. The ``llm_model`` / ``embed_model`` constructor argument on ``LangChainHook``.
2. ``extra["model"]`` / ``extra["embed_model"]`` on the connection.
If neither is set, the hook raises a ``ValueError`` when the model is needed.
Examples
--------
**OpenAI (chat and embeddings)**
.. code-block:: json
... |
combine_chunk_553 | combine.txt | 553 | 512 | backs ``PydanticAIVertexHook``, the dedicated subclass of
``PydanticAIHook`` for Google Cloud's project/location/service-account
credential shape, which does not fit the plain ``api_key`` + ``base_url``
shape that the generic :doc:`pydantic_ai` connection assumes. All fields live
in ``extra``; the ``password`` and ``h... |
combine_chunk_554 | combine.txt | 554 | 512 | back to the ``GOOGLE_CLOUD_PROJECT``
environment variable.
Location / Region
Vertex AI region (e.g. ``us-central1``). Falls back to the
``GOOGLE_CLOUD_LOCATION`` environment variable.
Force Vertex AI Mode
Not needed: the ``google-cloud:`` model prefix above already makes
``GoogleCloudProvider`` b... |
combine_chunk_555 | combine.txt | 555 | 512 | ``gcloud auth application-default login``, Workload Identity, …), used
automatically once ``project`` and/or ``location`` are set without
``service_account_info``.
- ``api_key``: for Vertex AI Express Mode, only used when none of the above
are set.
Examples
--------
**Application Default Credentials (recommen... |
combine_chunk_556 | combine.txt | 556 | 512 |
decision. They are two layers of a ladder that runs from fully hardcoded to
fully model-driven, with the SDK's ``ExceptionRetryPolicy`` as the bottom rung:
.. list-table::
:header-rows: 1
:widths: 22 40 38
* - Layer
- What decides
- How you tune it
* - **Fallback rules**
(``ExceptionRetr... |
combine_chunk_557 | combine.txt | 557 | 512 | running batch
instead of paying for it again (:ref:`llm-batch-reattach`).
For the core retry policy concepts, see :doc:`apache-airflow:core-concepts/tasks`.
If the task also needs to survive a worker crash without losing its progress,
see :ref:`apache-airflow:concepts-resumable-tasks-retry-policies`.
Setup
-----
1.... |
combine_chunk_558 | combine.txt | 558 | 512 | names in ``categories``; it
sees each category's name and description in the output schema and cannot
answer with a name outside the set.
3. The policy returns RETRY or FAIL. For ``LLMRetryPolicy`` that is the model's
``should_retry`` and ``suggested_delay_seconds``. For ``ClassifierRetryPolicy``
it is the... |
combine_chunk_559 | combine.txt | 559 | 512 | . Failing over to another vendor *within*
an attempt is a separate mechanism on the connection; see
:doc:`provider_fallback`, which also sets out how the two layers compose.
ClassifierRetryPolicy
---------------------
``ClassifierRetryPolicy`` takes the retry decision away from the model. Its
``categories`` maps a ca... |
combine_chunk_560 | combine.txt | 560 | 512 | edit what you need:
.. code-block:: python
from dataclasses import replace
from datetime import timedelta
from airflow.providers.common.ai.policies.retry import (
ClassifierRetryPolicy,
DEFAULT_CATEGORIES,
ErrorCategory,
)
ClassifierRetryPolicy(
llm_conn_id="pyda... |
combine_chunk_561 | combine.txt | 561 | 512 | ``timedelta``, not seconds, and is used as-is: a task's own
``max_retry_delay`` does not clamp it. ``delay=None`` (the default) means no
override, so the task's own ``retry_delay`` / ``retry_exponential_backoff`` /
``max_retry_delay`` apply instead (see :doc:`apache-airflow:core-concepts/tasks`).
``retry=False`` ends ... |
combine_chunk_562 | combine.txt | 562 | 512 | text model, remove the bar.
The confidence is a statistic on the shape of the probability distribution the
model returned: concentrated on one category is high, spread out is low. It is
not the probability that the answer is correct. Pick the bar from the confidence
values your own failures produce: run the policy wi... |
combine_chunk_563 | combine.txt | 563 | 512 | `` still holds when both models
are unreachable.
``fallback_policy`` accepts any ``RetryPolicy``. An ``ExceptionRetryPolicy`` works
there too; its ``default`` is what it returns when none of its rules match, so
``default=RetryAction.FAIL`` fails every unsure classification and the outer
rules never run. Without ``m... |
combine_chunk_564 | combine.txt | 564 | 512 | stops matching. Match ``pydantic_ai.exceptions.FallbackExceptionGroup``
explicitly as well; its only common ancestor with ``ModelAPIError`` is ``Exception``, too
broad to write a rule against. The original per-model exceptions are still available on
``FallbackExceptionGroup.exceptions``, but ``RetryRule`` only compare... |
combine_chunk_565 | combine.txt | 565 | 512 | not explain
itself; the first two come from the category's entry, and the explanation is
the generated line in the task log, which says what mattered (the category,
the confidence, the bar, the action). A model cannot return a category the
policy does not recognize, and it cannot return a category paired with an
actio... |
combine_chunk_566 | combine.txt | 566 | 512 | instructions`` there to teach the model your
error strings when a description is not enough on its own, and leave the
category names, actions and delays to the table; a prompt that names them only
spends tokens, because the model is constrained to the table's names and does
not decide the action:
.. code-block:: pytho... |
combine_chunk_567 | combine.txt | 567 | 512 | only on
``ClassifierRetryPolicy``.
.. list-table::
:header-rows: 1
:widths: 20 15 65
* - Parameter
- Default
- Description
* - ``llm_conn_id``
- (required)
- Airflow connection ID for the LLM provider.
* - ``model_id``
- None
- Override the model from the connection (e.g.... |
combine_chunk_568 | combine.txt | 568 | 512 | is used; a DEFAULT, whatever its reason, means the outer ``fallback_rules``
apply.
* - ``redactor``
- None (uses ``redact_registered_secrets``)
- Callable ``(str) -> str`` applied to the exception text (its string
representation, or the whole traceback with ``include_traceback=True``)
... |
combine_chunk_569 | combine.txt | 569 | 512 | from airflow.providers.common.ai.policies.retry import LLMRetryPolicy
from airflow.sdk import task
@task(retries=3, retry_policy=LLMRetryPolicy(llm_conn_id="pydanticai_default", include_traceback=True))
def fetch_orders():
with urlopen("https://api.example.com/orders") as response:
tr... |
combine_chunk_570 | combine.txt | 570 | 512 | your own ``redactor`` callable. It **replaces** the
default masker rather than running in addition to it, so combine your own
logic with :func:`~airflow.providers.common.ai.policies.retry.redact_registered_secrets`
yourself if you still want known-secret masking too:
.. code-block:: python
import re
from ai... |
combine_chunk_571 | combine.txt | 571 | 512 | copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for t... |
combine_chunk_572 | combine.txt | 572 | 512 | with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either exp... |
combine_chunk_573 | combine.txt | 573 | 512 | .ai/>`__ -- a higher-throughput alternative,
commonly GPU-hosted; see its
`GPU installation requirements <https://docs.vllm.ai/en/latest/getting_started/installation/gpu/>`__.
- `LM Studio <https://lmstudio.ai/>`__ -- a desktop app with a built-in
OpenAI-compatible server; see its
`system requirements <https://... |
combine_chunk_574 | combine.txt | 574 | 512 | :sync: lmstudio
Download a model, load it, then start the server:
.. code-block:: bash
lms get gemma4
lms load gemma4
lms server start
See `LM Studio's CLI docs <https://lmstudio.ai/docs/cli>`__ for the
full ``lms`` reference (you can also ... |
combine_chunk_575 | combine.txt | 575 | 512 | and does send
that placeholder in the actual HTTP request. A server with no auth check
doesn't care, so the request still succeeds either way.
- ``extra["model"]`` -- ``ollama:<model>`` picks up Ollama-specific tuning;
vLLM and LM Studio have no dedicated pydantic-ai provider class, so they
use ``openai:<model... |
combine_chunk_576 | combine.txt | 576 | 512 | against the same connection
with no changes.
.. tab-item:: vLLM
:sync: vllm
vLLM needs extra server startup flags to enable tool calling for a
given model (``--enable-auto-tool-choice`` plus a matching
``--tool-call-parser``) -- see its
`Tool Calling docs <https://... |
combine_chunk_577 | combine.txt | 577 | 512 | _model_ready:
Waiting for an Ollama model to load
-------------------------------------
Ollama loads a model into memory on the first request. pydantic-ai's default
HTTP read timeout is 600 seconds, longer than the 300 seconds used below, so with
default settings the agent's first request waits for the load itself. L... |
combine_chunk_578 | combine.txt | 578 | 512 | )
The load request does not send ``keep_alive``, so Ollama unloads the model after
its own keep-alive time (5 minutes by default) like any other model. If the
downstream LLM task can wait in the queue longer than that, raise the server's
default with the ``OLLAMA_KEEP_ALIVE`` environment variable.
The upstream task a... |
combine_chunk_579 | combine.txt | 579 | 512 | llamaBackend`` as the factory
(``base_url`` may keep its ``/v1`` suffix). When the connection has no host,
``OllamaBackend`` uses the ``OLLAMA_BASE_URL`` environment variable, and raises
``ValueError`` if that is not set either:
.. code-block:: python
from airflow.providers.common.ai.hooks.ollama import OllamaBac... |
combine_chunk_580 | combine.txt | 580 | 512 | use one of the
OpenAI prefixes: ``openai:<model>`` for the Responses API or
``openai-chat:<model>`` for Chat Completions. pydantic-ai's ``openai``
provider class talks to whatever ``host`` points at, so either works against
vLLM's OpenAI-compatible API even though the weights being served aren't
OpenAI's.
- ... |
combine_chunk_581 | combine.txt | 581 | 512 | server's
OpenAI-compatible endpoint the same way as the vLLM example above.
Cross-hook naming differences
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:class:`~airflow.providers.common.ai.hooks.langchain.LangChainHook` also
supports self-hosted endpoints through the same ``host`` connection field,
forwarding it to the same constr... |
combine_chunk_582 | combine.txt | 582 | 512 | .
- pydantic-ai isn't limited to Ollama and vLLM -- any OpenAI-compatible
endpoint works the same way. See the
`pydantic-ai install docs <https://ai.pydantic.dev/install/#slim-install>`__
for the full list of providers it supports.
- `pydantic-ai's OpenAI-compatible models docs
<https://pydantic.dev/docs/ai/mod... |
combine_chunk_583 | combine.txt | 583 | 512 | :doc:`SQLToolset <sql>`
- ``list_tables``, ``get_schema``, ``query`` and ``check_query`` against a DBAPI
database
- ``allowed_tables``, ``allow_writes`` (off by default), ``max_rows``,
``max_result_bytes``
* - :doc:`ObjectStorageToolset <object_storage>`
- ``list_files``, ``get_file_inf... |
combine_chunk_584 | combine.txt | 584 | 512 | its
own sandbox (:doc:`../tool_approval` lists every limit). ``.filtered()`` drops tools
from what the model is offered, as the :ref:`MCP guide <howto/toolset:mcp-filtered>`
shows. ``.defer_loading()`` hides a toolset's tools from the model until it searches for
them, which pays off on a toolset with many tools (see :... |
combine_chunk_585 | combine.txt | 585 | 512 | <https://ai.pydantic.dev/toolsets/>`__ interface, so it works in any
pydantic-ai ``Agent``. ``AgentOperator`` accepts any ``AbstractToolset`` too, such as
pydantic-ai's own ``MCPToolset`` or a third-party toolset; those miss the connection
handling the toolsets on this page add. To write a toolset of your own on the s... |
combine_chunk_586 | combine.txt | 586 | 512 | object store that the agent should read the way a person would:
browse a directory, open a report, look at the first rows of a Parquet file
- ``ObjectStorageToolset``
* - Files on an object store (Parquet, CSV, Avro) or a catalog-managed
table format such as Iceberg, to query with SQL rather than... |
combine_chunk_587 | combine.txt | 587 | 512 |
- Worker process, against the store
* - ``DataFusionToolset``
- ``conn_id`` on each ``DataSourceConfig``
- Worker process (embedded engine)
* - ``MCPToolset``
- ``mcp_conn_id``, unless ``token_provider`` or ``env_provider`` supplies
one from elsewhere
- Remote server, or a child p... |
combine_chunk_588 | combine.txt | 588 | 512 | iberately, because the wait it introduces is remote. ``ObjectStorageToolset``
leaves it unset, so its calls are not barriers, but each of them still waits for a
hook, SQL or DataFusion call in progress: the hook, SQL, DataFusion and object storage
toolsets run their blocking work in worker threads under one lock per ta... |
combine_chunk_589 | combine.txt | 589 | 512 | toolset to give its tools a budget of their own. Once the budget is
used up the run fails, and Airflow's task retries take over.
.. code-block:: python
AgentOperator(
task_id="revenue_agent",
prompt="What was last week's revenue?",
llm_conn_id="pydanticai_default",
toolsets=[SQLTo... |
combine_chunk_590 | combine.txt | 590 | 512 | pydantic_ai.Agent`` yourself:
.. exampleinclude:: /../../ai/src/airflow/providers/common/ai/example_dags/example_pydantic_ai_hook.py
:language: python
:start-after: [START howto_task_with_toolsets]
:end-before: [END howto_task_with_toolsets]
This works because toolsets resolve Airflow connections lazily v... |
combine_chunk_591 | combine.txt | 591 | 512 | .
See also
--------
- :doc:`../agent_security`: defense layers, ``allowed_tables`` enforcement, ``HookToolset``
guidelines and the production checklist.
- :doc:`../security`: the provider's security policy.
- :doc:`../examples`: the example Dags referenced above.
<|file|>airflow/providers/common/ai/docs/toolsets/l... |
combine_chunk_592 | combine.txt | 592 | 512 | already contains one,
including inside a combined or wrapper capability, the operator does not add
another, so the logger on the supplied instance is used.
For an agent you build yourself, pass the capability to any pydantic-ai ``Agent``:
.. code-block:: python
from pydantic_ai import Agent
from airflow.pr... |
combine_chunk_593 | combine.txt | 593 | 512 | toolset's tools until the model searches for them, so
an agent can carry a wide toolset and pay mostly for the tools a run looks for. It is a
Pydantic AI method that every toolset has, including the ones this provider ships. Use it
on toolsets with many tools, and leave a tool no run needs out of the toolset altogethe... |
combine_chunk_594 | combine.txt | 594 | 512 | : python
:dedent: 4
:start-after: [START howto_toolset_defer_loading_some]
:end-before: [END howto_toolset_defer_loading_some]
The names are the tool names the model sees, so they include ``tool_prefix``. A name that
matches no tool is ignored without an error, so a misspelled name leaves that tool visible... |
combine_chunk_595 | combine.txt | 595 | 512 | , cache_write_tokens=1745
Tool call sequence: s3_list_keys -> s3_read_key -> s3_read_key
::endgroup::
The local search matches each keyword on its own, so one search can reveal more tools than
the model goes on to use. In a run where the model searched for ``list keys read key``,
the search revealed six of the... |
combine_chunk_596 | combine.txt | 596 | 512 | a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for... |
combine_chunk_597 | combine.txt | 597 | 512 | ``apache-airflow-providers-http``, a model connection named
``pydanticai_default``, and an HTTP connection named ``pypi`` whose host is
``https://pypi.org``, for example:
.. code-block:: bash
export AIRFLOW_CONN_PYPI='{"conn_type": "http", "host": "https://pypi.org"}'
When the model calls ``get_release`` for ve... |
combine_chunk_598 | combine.txt | 598 | 512 | .TypedDict`` raises ``PydanticUserError: Please use
`typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.12.``, and
the Dag file fails to import.
``execute_tool``
Runs one call. ``name`` says which tool, and ``tool_args`` holds the arguments
``args_validator`` returned. Return the ... |
combine_chunk_599 | combine.txt | 599 | 512 | _retries``, the agent's ``retries``. Once they are used up, the run fails with
``UnexpectedModelBehavior``, whose message starts ``Tool 'get_package' exceeded max
retries count of 1`` under the default ``retries``. The
example raises ``ModelRetry`` for a package that does not exist, and the model reads:
.. cod... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.