From ab9a3240a9da941fdef5cd4a25f2b97c2f5a67aa Mon Sep 17 00:00:00 2001 From: Olivier Chafik Date: Fri, 12 Apr 2024 19:43:38 +0100 Subject: =?UTF-8?q?JSON=20schema=20conversion:=20=E2=9A=A1=EF=B8=8F=20fast?= =?UTF-8?q?er=20repetitions,=20min/maxLength=20for=20strings,=20cap=20numb?= =?UTF-8?q?er=20length=20(#6555)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * json: rename python schema converter to make import easier * server: skip null json_schema / grammar fields * json: deps management for primitive rules (+ allow null values) * json: optimize repetitions for minItems/maxItems and regexps: `a{,3}` goes from `"a"? "a"? "a"?` (explosive combos) to `(a (a (a)?)?)?` * grammars: add troubleshooting section to readme * json: cap length of numbers to 15 digits before/after decimal point (avoids infinite gen, e.g. "one third" -> `0.333333333333...`) * json: unify all repetition code (w/ or w/o sep) * json: support string minLength/maxLength * server+json: update server/README w/ result_format * nits * json: fix type error w/ python 3.8 * json: fix server/README (json_schema in /completion vs. result_format in /v1/chat/completions) * json: simplify DOT `{"type": "string", "pattern": "^.$"}` * json: remove recursion in opt_repetitions (avoids Python stack overflow) * json: rm dead code * json: rm useless assert & ggml.h import --- tests/test-json-schema-to-grammar.cpp | 243 +++++++++++++++++++++------------- 1 file changed, 150 insertions(+), 93 deletions(-) (limited to 'tests') diff --git a/tests/test-json-schema-to-grammar.cpp b/tests/test-json-schema-to-grammar.cpp index 4d110cf5..b2ce4d26 100755 --- a/tests/test-json-schema-to-grammar.cpp +++ b/tests/test-json-schema-to-grammar.cpp @@ -104,16 +104,16 @@ static void test_all(const std::string & lang, std::function test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE); + "python ./examples/json_schema_to_grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE); tc.verify(read("test-grammar-output.tmp")); }); } else { -- cgit v1.2.3