Use of bool instead of Literal["yes", "no"]?
#192
deanwampler
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working through the tutorial. In Using Generative slots to Provide Compositionality Across Module Boundaries, I noticed I could replace the use of
Literal["yes", "no"]withboolin both the function definitions that return this type and the conditionals at the bottom of the example that use them, e.g., replacing:with this:
This is more concise, more consistent with "normal" Python code conventions, and it adds extra type safety. Is there any particular reason for preferring the
Literalapproach?Related question: coercing a model to output
trueorfalseis pretty easy. Can Mellea (or whatever library it uses...) handle more complex type coercions, like structures?Beta Was this translation helpful? Give feedback.
All reactions