Lee-W commented on code in PR #74695:
URL: https://github.com/apache/airflow/pull/74695#discussion_r4311586204


##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm.py:
##########
@@ -220,7 +221,7 @@ def __init__(
         model_id: str | None = None,
         fallback_conn_ids: list[str] | None = None,
         system_prompt: str = "",
-        output_type: type | UnionType = str,
+        output_type: type | UnionType | Sequence[type] = str,

Review Comment:
   `LLMOperator`, `LLMFileAnalysisOperator`, `AgentOperator` and 
`rehydrate_pydantic_output` now reuse `is_model_dump_required`, so a model 
returned under `output_type=[MyModel, int]` is pushed as a `dict` on those 
return paths, including the `LLMOperator` review path. A single type or a union 
still returns an instance.
   
   `LLMFileAnalysisOperator` overrides `execute`, so it had its own copy of the 
check and needed the same change. Added `[Model, int]` tests for each path, and 
updated the `output_type` docstrings and docs that said the model is pushed 
unchanged.
   
   Behavior change: `rehydrate_pydantic_output([A, int], ...)` with 
`serialize_output=False` now returns a `dict` where it used to return the model.



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