Quantization-LLM / llama.cpp /tests /run-json-schema-to-grammar.mjs
KBaba7's picture
Upload 7646 files
a1a4268 verified
raw
history blame contribute delete
402 Bytes
import { readFileSync } from "fs"
import { SchemaConverter } from "../examples/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())