phanikumv commented on code in PR #76975:
URL: https://github.com/apache/airflow/pull/76975#discussion_r4640778991


##########
providers/common/ai/src/airflow/providers/common/ai/batch/pydantic_ai_backend.py:
##########
@@ -809,6 +928,164 @@ def extract_output(self, raw: RawResultItem, spec: 
OutputSpec) -> ExtractedOutpu
         return ExtractedOutput(kind="absent")
 
 
+class OpenAIBatchAdapter(PydanticAIBatchAdapter):
+    """
+    Batch adapter for OpenAI's Batch API, on the Responses API 
(``/v1/responses``).
+
+    pydantic-ai batches only its Responses model, so an ``openai-chat:`` model 
id is built as the
+    ``openai:`` model of the same name and logged. Azure OpenAI has no 
adapter. A batch's group
+    includes the model, so every request must use the same one. Raw Responses 
fields in
+    ``request_params`` (``user``, ``metadata``, ...) go through 
``extra_body``; the typed form of
+    a setting is preferred where one exists (``openai_reasoning_effort``, not 
``reasoning_effort``).

Review Comment:
   The adapter already fails fast on the six unsupported settings. Could it 
also fail fast on the Chat Completions keys that have a Responses equivalent? 
   
   For  example:
   
   ```
   
     _CHAT_COMPLETIONS_RENAMES = {
         "reasoning_effort": "openai_reasoning_effort",
         "verbosity": "openai_text_verbosity",
     }
   
   ```
     You could check this in _build_settings (or in an OpenAIBatchAdapter 
override) and raise:
   ```
   
     LLMBatchInputError(
         f"{key!r} is a Chat Completions parameter; batches run on the 
Responses API, use {renamed!r}"
     )
   ```
   
     The docstring could then say: use Responses field names for raw 
parameters, for example `openai_reasoning_effort` or `reasoning={"effort": 
...}`, not
     `reasoning_effort`.



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