Rig WASM Compiler is a tool that enables the compilation of Rig applications to WebAssembly (WASM), allowing Rig-based LLM applications to run seamlessly in web browsers.
- Compile Rig applications to WASM
- Run Rig Agents and RAG Agents in web browsers
- WASM-compatible adapters for HTTP clients and vector stores
- Easy integration with existing web projects
- Optimized for performance in browser environments
To install the Rig WASM Compiler, ensure you have Rust and Cargo installed, then run:
cargo install rig-wasm-compiler
- Create a Rig application (e.g.,
my_rig_app.rs
). - Compile it to WASM:
rig-wasm-compiler my_rig_app.rs --output dist
- Include the generated WASM module in your web project:
<script type="module">
import init, { WasmAgent } from './dist/my_rig_app.js';
async function run() {
await init();
const agent = new WasmAgent();
const result = await agent.process("Hello, Rig!");
console.log(result);
}
run();
</script>
For detailed documentation, including API reference and advanced usage, visit our documentation page.
Check out the examples/
directory for sample Rig applications compiled to WASM:
simple_agent.rs
: A basic Rig agent running in the browserrag_agent.rs
: A RAG (Retrieval-Augmented Generation) agent with WASM-compatible vector store
To set up the development environment:
-
Clone the repository:
git clone https://github.com/yourusername/rig-wasm-compiler.git cd rig-wasm-compiler
-
Install dependencies:
cargo build
-
Run tests:
cargo test
To run WASM-specific tests:
wasm-pack test --headless --firefox
This command runs the tests in a headless Firefox browser. Make sure you have Firefox installed.
To build your Rig application for WASM:
-
Ensure you have
wasm-pack
installed:cargo install wasm-pack
-
Build your project:
wasm-pack build --target web
This will generate WASM files in the pkg/
directory.
rig-wasm-compiler/
├── src/
│ ├── lib.rs # Main library code
│ ├── main.rs # CLI entry point
│ ├── config.rs # Configuration structures
│ ├── wasm_bindings/ # WASM-specific bindings
│ ├── adapters/ # WASM-compatible adapters
│ └── utils/ # Utility functions
├── examples/ # Example Rig applications
├── tests/ # Integration and WASM tests
├── www/ # Web demo files
└── build.rs # Custom build script
We welcome contributions! Please see our Contributing Guide for more details on how to get started.
- Fork the repository and create your branch from
main
. - If you've added code that should be tested, add tests.
- If you've changed APIs, update the documentation.
- Ensure the test suite passes.
- Make sure your code lints.
- Issue that pull request!
This project is licensed under the MIT License - see the LICENSE file for details.
- The Rig team for their excellent AI framework
- The Rust and WebAssembly working group for their tools and documentation
For questions, suggestions, or discussions, please open an issue on GitHub or contact us at your-email@example.com.
Made with ❤️ by the Rig community