Lee-W commented on code in PR #74695:
URL: https://github.com/apache/airflow/pull/74695#discussion_r4545464007
##########
providers/common/ai/src/airflow/providers/common/ai/utils/output_type.py:
##########
@@ -82,12 +142,16 @@ def rehydrate_pydantic_output(
"""
if output_type is str:
return raw
+ declared_type = output_type
try:
+ if isinstance(output_type, (list, tuple)):
+ # pydantic-ai treats a list of output types as "any of these".
+ output_type = reduce(operator.or_, output_type)
adapter: TypeAdapter[Any] = TypeAdapter(output_type)
is_output_function = _is_output_function(adapter.core_schema)
# A pydantic-ai output marker (``ToolOutput``, ``NativeOutput``, ...) is
not a type, and
- # ``TypeAdapter`` fails on it with an ``AttributeError``.
- except (PydanticUserError, AttributeError):
+ # ``TypeAdapter`` fails on it with an ``AttributeError``. Unioning an
empty list or markers is a ``TypeError``.
+ except (PydanticUserError, AttributeError, TypeError):
Review Comment:
Done. Only the `reduce` that joins a list of output types catches
`TypeError` now; a `TypeError` from `TypeAdapter(...)` propagates.
--
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]