From b333b06772c89d96aacb5490d6a219fba7c09cc6 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 12 Feb 2026 20:57:17 +0100 Subject: Engage! --- llama.cpp/examples/regex_to_grammar.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 llama.cpp/examples/regex_to_grammar.py (limited to 'llama.cpp/examples/regex_to_grammar.py') diff --git a/llama.cpp/examples/regex_to_grammar.py b/llama.cpp/examples/regex_to_grammar.py new file mode 100644 index 0000000..5cd9210 --- /dev/null +++ b/llama.cpp/examples/regex_to_grammar.py @@ -0,0 +1,20 @@ +import json, subprocess, sys, os + +assert len(sys.argv) >= 2 +[_, pattern, *rest] = sys.argv + +print(subprocess.check_output( + [ + "python", + os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "json_schema_to_grammar.py"), + *rest, + "-", + "--raw-pattern", + ], + text=True, + input=json.dumps({ + "type": "string", + "pattern": pattern, + }, indent=2))) -- cgit v1.2.3