Detalhes do pacote

@mlc-ai/web-xgrammar

mlc-ai407Apache-2.00.1.0

This folder contains the source code and emcc bindings for compiling XGrammar to Javascript/Typescript via emscripten.

machine_learning, llm, nlp

readme (leia-me)

web-xgrammar

This folder contains the source code and emcc bindings for compiling XGrammar to Javascript/Typescript via emscripten.

Build from source

  1. Install emscripten. It is an LLVM-based compiler that compiles C/C++ source code to WebAssembly.

    • Follow the installation instruction to install the latest emsdk.
    • Source emsdk_env.sh by source /path/to/emsdk_env.sh, so that emcc is reachable from PATH and the command emcc works.
    • We can verify the successful installation by trying out emcc in the terminal.
  2. Modify the content of cmake/config.cmake to be web/config.cmake.

  3. Run the following

     source /path/to/emsdk_env.sh
     npm install
     npm run build
    

Example

To try out the test webpage, run the following

cd example
npm install
npm start

Testing

For testing in node environment, run:

npm test