cetingokhan opened a new pull request, #62816:
URL: https://github.com/apache/airflow/pull/62816

   This pull request refactors the model resolution logic in the 
`PydanticAIHook` to use a modular builder pattern, improving extensibility and 
clarity for handling different AI providers, especially Azure OpenAI. It 
introduces dedicated builder classes for Azure OpenAI, custom endpoints, and 
default resolution, and updates documentation and tests to match the new 
structure.
   
   **Builder pattern for model resolution:**
   
   * Added new builder classes: `AzureOpenAIBuilder`, `CustomEndpointBuilder`, 
`DefaultBuilder`, and a `ProviderBuilder` protocol in the `builders` package to 
modularize how models are constructed from Airflow connection details. 
[[1]](diffhunk://#diff-d1854c84b6c6196fef61024285e7bb3f1424f1a434a3f5507930158567cba3e5R1-R31)
 
[[2]](diffhunk://#diff-0a37576ea742b0fc055960de587a234457f0c7385de3c4ac0b3ff2180b058f50R1-R99)
 
[[3]](diffhunk://#diff-1592522b00129d036aebc50dcfbe3654e3ab2f61288cfde48944438911cc1630R1-R58)
 
[[4]](diffhunk://#diff-6c40bb2d6dde6e5186a35f360a251ae28d3ad997fc1859b7f2da85c9ebc98aebR1-R92)
   
   **Refactoring in `PydanticAIHook`:**
   
   * Replaced direct calls to `infer_model` and provider factory logic with a 
prioritized builder selection process (`AzureOpenAIBuilder` → 
`CustomEndpointBuilder` → `DefaultBuilder`), improving support for Azure OpenAI 
and custom endpoints.
   
   **Documentation and UI improvements:**
   
   * Updated docstrings and UI field behavior in `PydanticAIHook` to clarify 
connection fields for Azure OpenAI and provide examples for required extras 
like `api_version` and `azure_deployment`. 
[[1]](diffhunk://#diff-dd850d1a210dfcbdb51ec2fcb2ef47a967449aa4b683d6e7256cbc7a2b68055cL39-R58)
 
[[2]](diffhunk://#diff-dd850d1a210dfcbdb51ec2fcb2ef47a967449aa4b683d6e7256cbc7a2b68055cL78-R148)
   
   **Testing updates:**
   
   * Modified unit tests to patch `infer_model` and `infer_provider_class` from 
the new builder modules instead of the hook, ensuring tests match the 
refactored code structure. 
[[1]](diffhunk://#diff-d0cd7707473a4d994023a0ccdc500b47fec345067d38e9351604282d54d571e8L41-R43)
 
[[2]](diffhunk://#diff-d0cd7707473a4d994023a0ccdc500b47fec345067d38e9351604282d54d571e8L75-R77)
 
[[3]](diffhunk://#diff-d0cd7707473a4d994023a0ccdc500b47fec345067d38e9351604282d54d571e8L95-R97)
 
[[4]](diffhunk://#diff-d0cd7707473a4d994023a0ccdc500b47fec345067d38e9351604282d54d571e8L125-R126)
 
[[5]](diffhunk://#diff-d0cd7707473a4d994023a0ccdc500b47fec345067d38e9351604282d54d571e8L142-R144)
   
   **Connection validation enhancements:**
   
   * Improved connection testing to validate Azure-specific requirements 
(presence of `api_version` and `host`) and clarified error handling for missing 
model configuration. <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull 
request.
   Write a good git commit message following this guide: 
http://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the 
documentation.
   
   Feel free to ping (in general) for the review if you do not see reaction for 
a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we 
sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [x] Yes (please specify the tool below)
   Cloude Sonnet 4.6 & Gemini 3.1 Pro
   Filled some of methods scope and tests created via copilot
   
   <!--
   Generated-by: [Tool Name] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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]

Reply via email to