Log in
Log into community
Find answers from the community
View all posts
Related posts
Did this answer your question?
π
π
π
Powered by
Hall
Inactive
Updated 2 months ago
0
Follow
Type
Type
Inactive
0
Follow
N
Niels
7 months ago
Β·
Why do I not get type safety here if I explicitly pass the output_cls?
Attachment
L
N
9 comments
Share
Open in Discord
L
Logan M
7 months ago
I thiiink i5s because it's just typed as BaseModel, because we can't know your class ahead of time?
Maybe there's a better way to use generics here, open a to a pr!
N
Niels
7 months ago
Ahhh ok, is there no way to infer the return type based on a param that is a class? I am kind of a python newbie so it will probably be difficult to contribute
N
Niels
7 months ago
Was just confused because the docs said this:
https://docs.llamaindex.ai/en/stable/examples/output_parsing/openai_pydantic_program/
Attachment
L
Logan M
7 months ago
It is a valid pydantic object π But pythons type-checking is... hard to work with for dynamic stuff like this.
L
Logan M
7 months ago
You can safely cast it if you need type hints to work later on
N
Niels
7 months ago
Why canβt the function itself cast it to the given type then π
N
Niels
7 months ago
Will do some research on this haha, feels like it should be easy
L
Logan M
7 months ago
because python is spooky? Idk actually haha
L
Logan M
7 months ago
I havent looked much deeper, I feel like the solution here might be generics. But let me know if you find anything
Add a reply
Sign up and join the conversation on Discord
Join on Discord