implement union type support for streaming actions#813
Open
ThyTran1402 wants to merge 2 commits into
Open
Conversation
Contributor
|
Thanks for picking this up and for writing out the investigation so clearly. One small thought from my earlier pass on this issue: adding object to the union does make the type checker accept union values, but it also effectively widens stream_type to almost any value. That may still be the pragmatic choice here, but maintainers may prefer either a more explicit alias/comment around why the parameter is intentionally broad, or a small runtime/type-helper path that recognizes union forms while keeping the public intent narrow. The focused tests for both yping.Union[...] and ModelA | ModelB look useful. Thanks again for moving this forward. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the
@streaming_action.pydantic()decorator to accept union types likeModel1 | Model2orUnion[Model1, Model2]) for thestream_typeparameter. Previously, only single BaseModel types ordictwere accepted, limiting flexibility for streaming actions that yield multiple result types.Changes
How I tested this
Unit Tests: Created comprehensive test suite with 10 tests that all pass
Notes
Resolved: #607
Checklist