Skip to content

Latest commit

 

History

History
150 lines (104 loc) · 3.76 KB

README.md

File metadata and controls

150 lines (104 loc) · 3.76 KB

Rig WASM Compiler

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.

Features

  • 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

Quick Start

Installation

To install the Rig WASM Compiler, ensure you have Rust and Cargo installed, then run:

cargo install rig-wasm-compiler

Usage

  1. Create a Rig application (e.g., my_rig_app.rs).
  2. Compile it to WASM:
rig-wasm-compiler my_rig_app.rs --output dist
  1. 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>

Documentation

For detailed documentation, including API reference and advanced usage, visit our documentation page.

Examples

Check out the examples/ directory for sample Rig applications compiled to WASM:

  • simple_agent.rs: A basic Rig agent running in the browser
  • rag_agent.rs: A RAG (Retrieval-Augmented Generation) agent with WASM-compatible vector store

Development

To set up the development environment:

  1. Clone the repository:

    git clone https://github.com/yourusername/rig-wasm-compiler.git
    cd rig-wasm-compiler
  2. Install dependencies:

    cargo build
  3. Run tests:

    cargo test

Running WASM Tests

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.

Building for WASM

To build your Rig application for WASM:

  1. Ensure you have wasm-pack installed:

    cargo install wasm-pack
  2. Build your project:

    wasm-pack build --target web

This will generate WASM files in the pkg/ directory.

Project Structure

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

Contributing

We welcome contributions! Please see our Contributing Guide for more details on how to get started.

Submitting Pull Requests

  1. Fork the repository and create your branch from main.
  2. If you've added code that should be tested, add tests.
  3. If you've changed APIs, update the documentation.
  4. Ensure the test suite passes.
  5. Make sure your code lints.
  6. Issue that pull request!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • The Rig team for their excellent AI framework
  • The Rust and WebAssembly working group for their tools and documentation

Contact

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