-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the coverage of the JSON Schema specification #342
Conversation
3753612
to
e713a08
Compare
e713a08
to
6ea2407
Compare
We use the `referencing` library to dereference fields in the JSON Schema, which simplifies the codebase a lot and prevents reference errors. We also support combination of `minLength` and `maxLength` as well as the `pattern` keyword.
6ea2407
to
2f877cf
Compare
Regarding the |
We could, would that be useful? |
For our use case that would be super helpful. We are using LLMs to synthesize a lot of structured data. Frequently a single input maps to a list of different outputs, the exact number is not super important but it needs to be at least a few. Doing them in the same call leads to higher diversity in the outputs and much simpler pipelines. Two alternatives for us would be:
Both of these options are quite ugly compared to restricting the guided generation to a fixed number of items in the array. |
Noted, I added the feature. Don't hesitate to open an issue if there is something missing. |
In this PR I simplify the codebase by using the
referencing
library to dereference the specification. We also check the validity of the schema before compiling it. We add coverage for the following:minLength
andmaxLength
are both defined;pattern
keyword that allows to constrain the string to follow a regular expression;oneOf
,allOf
,anyOf
are now all properly covered;type
given an array valuearray
without a specified typeenums
without a specified typeTODO
Handle optional fields (those not specified in "required")minItems
for arraysmaxItems
for arraysNote
We cannot handle
minItems
andmaxItems
because of interegular's lack of support for lookaheads:Related issues
#330 #215