Lee-W commented on code in PR #76797: URL: https://github.com/apache/airflow/pull/76797#discussion_r4677905436
########## providers/databricks/docs/connections/pydantic_ai_databricks.rst: ########## @@ -0,0 +1,186 @@ + .. 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 (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/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 the + specific language governing permissions and limitations + under the License. + +.. _howto/connection:pydanticai_databricks: + +Pydantic AI (Databricks Model Serving) connection +================================================= + +The ``pydanticai_databricks`` connection type configures access to +`Databricks Model Serving <https://docs.databricks.com/aws/en/machine-learning/model-serving/>`__ +through its OpenAI-compatible Chat Completions API, via the pydantic-ai framework. It backs +``PydanticAIDatabricksHook``, the dedicated subclass of ``PydanticAIHook`` for Databricks. + +This connection type sources credentials from an existing +:ref:`Databricks connection <howto/connection:databricks>`, so the token-based authentication +methods that connection supports (OAuth, Azure AD, managed identity, federation) are reused and +refreshed on every request, except for the settings this hook rejects (see Authentication below). + +Install with: + +.. code-block:: bash + + pip install 'apache-airflow-providers-databricks[common.ai]' 'apache-airflow-providers-common-ai[openai]' + +The ``common.ai`` extra provides the Common AI hook this one builds on, but not the OpenAI client +the Chat Completions API calls go through, so also install ``apache-airflow-providers-common-ai[openai]``. + +Choosing a connection type +-------------------------- + +For a personal access token, a plain ``pydanticai`` connection is enough: set the Model to +``openai-chat:<endpoint>``, the Host to ``https://<workspace>/serving-endpoints`` and put the token +in Password (see :doc:`apache-airflow-providers-common-ai:connections/pydantic_ai`). Use +``pydanticai_databricks`` when you want to reuse an existing Databricks connection, or when the +credential needs a fresh token per request, such as OAuth for a service principal, Azure or +token federation. A personal access token also works with this connection type. + +Default Connection IDs +---------------------- + +The ``PydanticAIDatabricksHook`` uses ``pydanticai_databricks_default`` by default. + +Configuring the Connection +-------------------------- + +This connection type needs two connections: this one, and an existing ``databricks`` connection it +points at. All fields below are ``extra`` (JSON) fields on the ``pydanticai_databricks`` +connection; ``Schema``, ``Port``, ``Login``, ``Host``, and ``Password`` are hidden in the +connection form because the workspace host and credentials come from the Databricks connection +instead. + +Model + Serving endpoint name (e.g. ``my-serving-endpoint``). + + A bare name is resolved to ``openai-chat:<name>``, which uses the Chat Completions API. + Databricks documents querying chat models through the OpenAI client for + `Foundation Model APIs + <https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models>`__, + `external models <https://docs.databricks.com/aws/en/machine-learning/foundation-models/external-models>`__ and + `custom LLM endpoints + <https://docs.databricks.com/aws/en/machine-learning/model-serving/serve-custom-llms>`__ + served with the chat task. Databricks does not document Chat Completions for other endpoint types, + such as embedding or traditional ML endpoints; this hook is not intended for them. + + In pydantic-ai, the ``openai:`` prefix selects the Responses API and ``openai-chat:`` selects + Chat Completions, as described in the + `pydantic-ai OpenAI documentation <https://pydantic.dev/docs/ai/models/openai/>`__. An explicit + ``openai:<name>`` therefore sends Responses API requests. Databricks documents its Responses API + passthrough for OpenAI models; see + `Query chat models + <https://docs.databricks.com/aws/en/machine-learning/model-serving/query-chat-models>`__. + +Fallback Connections + Other connection IDs to fail over to, in order, while this provider is unavailable. Stored in + ``extra["fallback_conn_ids"]``. Entries may name any ``pydanticai`` connection type, so one + chain can span vendors. Fail-over also happens when the Databricks token endpoint cannot be + reached or keeps failing after its retries; a configuration error, such as unset or rejected Review Comment: Scoped it to the requests the hook retries itself: the Databricks token endpoint (OAuth service principal, federated token exchange) and the Azure instance metadata check. A failure inside an Azure or AWS credential library is now documented as failing the task. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
