Skip to content

Commit

Permalink
Add binary which converts JSON schemas to regex
Browse files Browse the repository at this point in the history
  • Loading branch information
414owen authored and torymur committed Dec 20, 2024
1 parent a3c300c commit c55f046
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ build-python-extension-release = "python setup.py build_rust --inplace --release

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }

[[bin]]
name = "convert-json-schema"
test = false
bench = false
8 changes: 8 additions & 0 deletions src/bin/convert-json-schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use outlines_core::json_schema::build_regex_from_schema;

fn main() {
let schema = std::io::read_to_string(std::io::stdin()).unwrap();
let regex = build_regex_from_schema(&schema, None).unwrap();
println!("Regex: {}", regex);
println!("Regex len: {}", regex.len());
}

0 comments on commit c55f046

Please sign in to comment.