-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Bug: JSON Schema - enum behind a $ref generates an object with unrestricted properties #8073
Comments
Hi @cikkle, thanks for the report! As you can see in the docs the support for external I guess we should probably find a way to issue warnings about it or even hard-fail (currently we just silently degrade to "anything goes" so the items in your example are just any json object), but in the meantime as a workaround you might wanna try and run Cheers |
Sorry, I might have a pretty basic misunderstanding as far as the spec, the docs, or the terms used. I took "external" to mean a reference to a schema in another file; the Anyhow, for my use case I don't have much of a problem with just copying enums around the schema where they need to go, but the fallback behavior did surprise me, so thanks for looking at this. |
Ohh sorry I completely misread your bug report, thanks for the clarification 🫣
It looks like it's a bug specific to the C++ implementation of the JSON Schema -> Grammar conversion, I'll try to send a fix shortly. In the meantime you can use |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
What happened?
I'm using the json_schema feature in llama-server. Using a simple prompt like
Write a dialog between Alice and Biff
, if I send a schema like:I get back an array of responses in the format I'd expect, like:
Things stop working right if I try to put the enums in separate definitions. The following schema:
...gives me arbitrary things like:
The output should follow the same format in both, but I get an object with random properties in place of the enum, and possibly more random things afterward (in this run, it was a bonus object tagging along, but it can vary).
Notably if I reorder the properties to put "dialog" before "character" I'll actually get the
dialog
property and string I asked for, so things only seem to go off the rails when it reaches one of the referenced enums.I'm aware json_schema currently has some known bugs and features yet to implemented, but I didn't see anything in the readme I thought this would fall under. Terminal output from llama-server doesn't appear to show anything relevant but it's included for completeness.
Name and Version
o0@hades:
/ai/llama.cpp$ ./llama-cli --version22.04) 11.4.0 for x86_64-linux-gnuversion: 3203 (b5a5f34)
built with cc (Ubuntu 11.4.0-1ubuntu1
What operating system are you seeing the problem on?
Linux
Relevant log output
The text was updated successfully, but these errors were encountered: