Skip to content

Conversation

@i-v-s
Copy link

@i-v-s i-v-s commented Nov 16, 2025

@ehoogeveen-medweb
Copy link

Depending on the implementation, there might be an ordering issue here: If " is escaped to \" and then \ is escaped to \\, " might get escaped to \\". Generally \ should be escaped first to avoid such issues - but I don't know if it's a problem here.

@i-v-s
Copy link
Author

i-v-s commented Nov 16, 2025

I think that twice replacement is not possible here, because the substitution result does not participates in the matching. My test shows that all works as expected:

$ ./debug/bin/llama-cli -m gemma-3-4B-it-Q8_0.gguf --json-schema '{"properties":{"code":{"const":"auto s = \"000\";","description":"Generated code","title":"Code","type":"string"}},"required":["code"],"title":"DecoderResponse","type":"object"}'

...

== Running in interactive mode. ==
 - Press Ctrl+C to interject at any time.
 - Press Return to return control to the AI.
 - To return control without starting a new line, end your input with '/'.
 - If you want to submit another line, end your input with '\'.
 - Not using system message. To change it, set a different value via -sys PROMPT


> AA
{"code":"auto s = \"000\";"}

@CISC
Copy link
Collaborator

CISC commented Nov 17, 2025

Please add a test to tests/test-json-schema-to-grammar.cpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: Symbol '\' is not escaped in the json schema literals.

3 participants