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

   ## Why
   
   `LLMBatchOperator.request_params` carries free-form provider body parameters
   (`temperature`, `top_k`, `seed`, `thinking`, ...) merged into every request. 
It is the batch
   counterpart of `LLMOperator.agent_params` / `AgentOperator.agent_params`, 
both of which are in
   `template_fields`, so a Dag author who writes 
`request_params={"temperature": "{{ params.temp }}"}`
   reasonably expects it to be rendered.
   
   It was not in `template_fields`. The Jinja expression stayed a literal 
string and was sent to the
   provider API as the parameter value, which fails at the provider with 
nothing pointing back at the
   operator parameter as the cause.
   
   `max_tokens` is deliberately left alone. Every scalar numeric parameter in 
this provider
   (`max_tokens`, `poll_interval`, `timeout`, 
`LLMFileAnalysisOperator.max_files`) is untemplated;
   only free-form dicts (`agent_params`, `embedding_kwargs`) and dicts with a 
known numeric schema
   (`usage_limits`, which also coerces each rendered value) are templated. 
Templating a bare `int`
   would hand the provider API the string Jinja produced.
   
   ## What
   
   - 
`providers/common/ai/src/airflow/providers/common/ai/operators/llm_batch.py` — 
add
     `request_params` to `template_fields`, and document the templating in its 
`:param:` entry.
     No coercion is applied, matching `agent_params`: the keys are provider 
body parameters whose
     types the operator does not know.
   - `providers/common/ai/docs/operators/llm_batch.rst` — document that 
`request_params` is
     templated, that Jinja hands back a string (so a numeric value written as a 
template needs
     `render_template_as_native_obj=True` on the Dag), and that the rendered 
values feed the
     re-attach fingerprint — the same stability rule that already applies to 
`result_path`.
   - `providers/common/ai/tests/unit/common/ai/operators/test_llm_batch.py` — 
add
     `TestTemplateFields`: one test pinning the `template_fields` set, one 
rendering
     `{"temperature": "{{ params.temp }}"}` through `render_template_fields`. 
Both fail without the
     operator change.
   
   Verified locally: the 50 tests in `test_llm_batch.py` pass; `prek run 
--from-ref upstream/main`
   is clean on both the `pre-commit` and `manual` stages. The 
Docker-image-based checks `breeze
   verify` lists (provider test suites, `build-docs`, `mypy-providers`) were 
not run locally — the
   Breeze image was not built on this machine — so CI covers those.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 5)
   
   Generated-by: Claude Code (Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


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