xgrammar
xgrammar copied to clipboard
[Web] Support structural tag for web-xgrammar package, update web to 0.1.18
This PR updates the web-xgrammar TypeScript package, mainly adding support for Structural Tag. There are two components to this PR:
- Address trivial changes to the APIs, including adding
any_whitespaceandebnfToGrammarNoNormalization(), and fixing any failed unit tests due to changes in the C++ source (see first commit6bccf6d) - Add structural tag support. Specifically, we export
StructuralTagItem,fromStructuralTag(), andcompileStructuralTag(). In addition, we addisGrammarAcceptString()for testing. Necessary changes are made toxgrammar_binding.cc
No change is needed outside of the web/ folder.
The structural tag feature is tested with TypeScript unit tests equivalent to test_grammar_matcher_structural_tag.py, and an E2E example in web/example/.
We subsequently publish 0.1.18 npm package https://www.npmjs.com/package/@mlc-ai/web-xgrammar