You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow up on #661 since that was closed before it was fixed
When streaming with a |, it crashes with TypeError: type 'types.UnionType' is not subscriptable
To Reproduce
importinstructorfrompydanticimportBaseModelfromopenaiimportOpenAIclassUser(BaseModel):
name: strage: intcategory: str|Noneclient=instructor.from_openai(OpenAI())
# Extract structured data from natural languageres=client.chat.completions.create_partial(
model="gpt-4o-mini",
response_model=User,
messages=[{"role": "user", "content": "John Doe is 30 years old."}],
)
res
Expected behavior
Swapping to Union works, but I expect them both to work
importinstructorfrompydanticimportBaseModelfromopenaiimportOpenAIclassUser(BaseModel):
name: strage: intcategory: Union[str, None]
client=instructor.from_openai(OpenAI())
# Extract structured data from natural languageres=client.chat.completions.create_partial(
model="gpt-4o-mini",
response_model=User,
messages=[{"role": "user", "content": "John Doe is 30 years old."}],
)
res
The text was updated successfully, but these errors were encountered:
What Model are you using?
gpt-4o-mini
Describe the bug
Follow up on #661 since that was closed before it was fixed
When streaming with a
|
, it crashes withTypeError: type 'types.UnionType' is not subscriptable
To Reproduce
Expected behavior
Swapping to Union works, but I expect them both to work
The text was updated successfully, but these errors were encountered: