guidance-ai / guidance

A guidance language for controlling large language models.
MIT License
18.81k stars 1.04k forks source link

JSON: type-narrow `enum`, `oneOf`, and `anyOf` #1038

Open hudson-ai opened 1 day ago

hudson-ai commented 1 day ago

If type keyword co-occurs with enum, oneOf, or anyOf, we should be able to "narrow" the choices based on that type.

e.g.

{"type": "string", "enum": ["1", "2", 3]}

->

{"enum": ["1", "2"]}

Note: we in general need to add "intersection" logic like this... e.g. $ref plus properties can be joined into a single schema. More general problem: allOf