-
Notifications
You must be signed in to change notification settings - Fork 10k
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
json
: better support for "type" unions (e.g. nullable arrays w/ typed items)
#7863
Conversation
…"], "items": {"type": "string"}}`)
Updating the integration tests with pass/fail cases for this one would help me understand better what's going on with this. |
I think we need #7790 for that ;-) In the meantime added an example to the PR's description, sorry it was a bit cryptic :-D |
json
: better support for "type" unions (e.g. nullable arrays w/ typed items)
haha, thanks. :) Noted -- I've been a bit slow on that one. It's finally updated and I think it's ready for review / merge. |
Looks like one of the tests is failing:
|
Fixed, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super, super clean.
To test I reverted the change to json-schema-to-grammar.cpp
and the integration test failed. Brought the changes in, and the integration test passed.
The changes are small and discrete and self-contained. Love it! ❤️❤️❤️ Enthusiastic approval -- very well done!!
…ed items) (ggerganov#7863) * json: better suport for "type" arrays (e.g. `{"type": ["array", "null"], "items": {"type": "string"}}`) * json: add test for type: [array, null] fix * update tests
…ed items) (ggerganov#7863) * json: better suport for "type" arrays (e.g. `{"type": ["array", "null"], "items": {"type": "string"}}`) * json: add test for type: [array, null] fix * update tests
Adds support for the following nullable syntax I've seen in the wild (also checked properly by https://www.jsonschemavalidator.net/):
Before this PR, the grammar above was treated like
{"anyOf": [{"type": "array"}, {"type": "null"}]}
(meaning it would accept to generate[123]
).With this PR, it ensures the array is typed, e.g.
["123"]
is possible but not[123]