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

   a generic `pydanticai` connection had no platform of its own, so a bare 
`model_id` failed with "Connection '...' has no default model provider, so the 
bare model name '...' cannot be resolved". a connection pointed at an 
OpenAI-compatible gateway made every DAG author pick the right pydantic-ai 
prefix, and `openai:` (Responses API) vs `openai-chat:` (Chat Completions) is 
easy to get wrong
   
   an optional `provider` key in the extra (shown in the form as Default 
Provider) now qualifies bare ids on a generic connection:
   
   ```json
   {"provider": "openai-chat"}
   ```
   
   with that set, `@task.llm(llm_conn_id="my_gateway", 
model_id="claude-sonnet-4-5")` resolves to `openai-chat:claude-sonnet-4-5`
   
   - the value is checked with the same `infer_provider_class` lookup the 
prefix check uses, so a typo raises when the model is resolved, even if the 
model id carries its own prefix
   - ids that already carry a recognized prefix are used as is, and connections 
without the key behave as before
   - vendor types (Azure/Bedrock/Vertex) keep their class-level 
`model_provider` and ignore the key, since their credential fields only fit 
their own platform
   - fallback chains use it too: a bare name forwarded to a generic fallback is 
qualified with that fallback's `provider`, and the colon-bearing-id gate 
compares it like a class attribute
   
   ```diff
     PydanticAIHook.get_conn()                hooks/pydantic_ai.py
     ├─ _resolve_own_model()
   + │  ├─ _get_model_provider()             # class attr, else 
extra["provider"]
     │  └─ _qualify_model_name()
   - │     └─ self.model_provider
   + │     └─ _get_model_provider()
     └─ _resolve_fallback_models()
   +    ├─ _get_model_provider()             # once, before the loop
   -    └─ _resolve_own_model(forwarded_model_provider=self.model_provider)
   +    └─ _resolve_own_model(forwarded_model_provider=<that value>)
   ```
   
   docs: the pydanticai connection page documents Default Provider and adds an 
OpenAI-compatible gateway example, and the troubleshooting, model providers, 
fallback and self-hosted pages no longer say a bare name always fails. 
`provider.yaml` gets the matching conn-field
   
   tested with `uv run pytest tests/unit/common/ai/hooks/test_pydantic_ai.py` 
from `providers/common/ai` (199 passed, 13 new), plus prek on the changed files 
and the provider mypy hook. I did not build the docs
   
   closes: #75906
   
   ---
   
   ##### 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)
   
   Generated-by: Claude Code (Claude Opus 5.5) 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`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


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