Is your feature request related to a problem? Please describe.
I've got a BaseModel with unionTypes and i cannot stream the attribute
from instructor import Partial
class MyResponse:
value: str | int
Partial[MyResponse]
1026 modified_args = tuple(_process_generic_arg(arg) for arg in generic_args)
1028 # Reconstruct the generic type with modified arguments
1029 tmp_field.annotation = (
-> 1030 generic_base[modified_args] if generic_base else None
1031 )
1032 # If the field is a BaseModel, then recursively convert it's
1033 # attributes to optionals.
1034 elif isinstance(annotation, type) and issubclass(annotation, BaseModel):
1035 # Prevent infinite recursion for self-referential models
TypeError: type 'types.UnionType' is not subscriptable
Describe the solution you'd like
A clear and concise description of what you want to happen.
I want to be able to stream MyResponse with the value that has union types.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
It's not that important, i can workaround and make it work by going toward a more general type like str or list[str]. But i guess for some users, and some usecases, it might be frustrating to not have support for union types.
We might also wait and hope a release of Pydantic that will do the heavy lifting on this part.
Additional context
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe.
I've got a BaseModel with unionTypes and i cannot stream the attribute
Describe the solution you'd like
A clear and concise description of what you want to happen.
I want to be able to stream MyResponse with the value that has union types.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
It's not that important, i can workaround and make it work by going toward a more general type like str or list[str]. But i guess for some users, and some usecases, it might be frustrating to not have support for union types.
We might also wait and hope a release of Pydantic that will do the heavy lifting on this part.
Additional context
Add any other context or screenshots about the feature request here.