summaryrefslogtreecommitdiff
path: root/llama.cpp/tests/run-json-schema-to-grammar.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'llama.cpp/tests/run-json-schema-to-grammar.mjs')
-rw-r--r--llama.cpp/tests/run-json-schema-to-grammar.mjs10
1 files changed, 10 insertions, 0 deletions
diff --git a/llama.cpp/tests/run-json-schema-to-grammar.mjs b/llama.cpp/tests/run-json-schema-to-grammar.mjs
new file mode 100644
index 0000000..450c3dd
--- /dev/null
+++ b/llama.cpp/tests/run-json-schema-to-grammar.mjs
@@ -0,0 +1,10 @@
+import { readFileSync } from "fs"
+import { SchemaConverter } from "../tools/server/public_legacy/json-schema-to-grammar.mjs"
+
+const [, , file] = process.argv
+const url = `file://${file}`
+let schema = JSON.parse(readFileSync(file, "utf8"));
+const converter = new SchemaConverter({})
+schema = await converter.resolveRefs(schema, url)
+converter.visit(schema, '')
+console.log(converter.formatGrammar())