@ondeinference / ed Mirror · read-only
Fork 0

Read-only mirror of github.com/ondeinference/ed.

Mirrored from https://github.com/ondeinference/ed.git

Synced Nov 23, 01:00 UTC

main
md 61 lines 2.09 KB
Rendered Raw
1 # web-chat
2
3 Ed running a model entirely in the browser. The page talks to a Web Worker
4 that owns one `Ed` instance compiled to `wasm32-unknown-unknown`. Nothing you
5 type is sent to a server.
6
7 ## Build and run
8
9 You need `wasm-pack` and the `wasm32-unknown-unknown` target.
10
11 ```bash
12 ./build.sh
13 python3 -m http.server -d www 8080
14 ```
15
16 Open <http://localhost:8080>. No bundler, npm or special headers are needed.
17 Cache Storage needs a secure context, which `localhost` counts as.
18
19 The browser engine lives in `onde` 1.5.0. Until it is released, build against
20 a local checkout:
21
22 ```bash
23 ./build.sh --config 'patch.crates-io.onde.path="../../../onde"'
24 ```
25
26 ## Deploy
27
28 The demo is published at <https://ondewebdemo.5mb.app> as a static site on
29 smbCloud (app `ondewebdemo`, in the Onde Inference project). It needs the `smb`
30 CLI 1.1.0 or newer and a prior `smb login`.
31
32 ```bash
33 ./build.sh --config 'patch.crates-io.onde.path="../../../onde"'
34 ./deploy.sh --dry-run # lists the files, uploads nothing
35 ./deploy.sh # publishes, then waits for /version.txt to match
36 ```
37
38 `deploy.sh` ships only `index.html`, `main.js`, `worker.js`, `style.css` and the
39 two files in `pkg/` that the page loads. Each deploy is a new release, and
40 `/version.txt` holds the commit it was built from (`-dirty` if the tree had
41 uncommitted changes). The site is static and needs no special headers.
42
43 ## What it downloads
44
45 Qwen 2.5 0.5B (GGUF, about 380 MB), once, on the first click of Download. It
46 is stored in the browser's Cache Storage for this origin, so a reload loads it
47 from disk without downloading again. **Remove model** in the footer deletes it.
48
49 ## Speed
50
51 Inference is CPU only, single threaded, using WebAssembly SIMD. Expect one to three
52 tokens per second on a laptop (measured 1.2 to 2.5 on an Apple Silicon Mac). Stop ends the worker and starts a new one, so it
53 also resets the conversation.
54
55 ## Layout
56
57 - `src/lib.rs`: the wasm-bindgen API (`WebChat`) around `Ed`.
58 - `www/worker.js`: owns the wasm module and the `WebChat`.
59 - `www/main.js`, `index.html`, `style.css`: the UI.
60
61 This crate is excluded from the root workspace and has its own lockfile.