Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions examples/web-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ python3 -m http.server -d www 8080
Open <http://localhost:8080>. No bundler, npm or special headers are needed.
Cache Storage needs a secure context, which `localhost` counts as.

The browser engine lives in `onde` 1.5.0. Until it is released, build against
a local checkout:
The browser engine comes from `onde` 1.5.0 on crates.io. To try a local `onde`
checkout instead, pass a patch through to cargo:

```bash
./build.sh --config 'patch.crates-io.onde.path="../../../onde"'
Expand All @@ -30,13 +30,14 @@ smbCloud (app `ondewebdemo`, in the Onde Inference project). It needs the `smb`
CLI 1.1.0 or newer and a prior `smb login`.

```bash
./build.sh --config 'patch.crates-io.onde.path="../../../onde"'
./build.sh
./deploy.sh --dry-run # lists the files, uploads nothing
./deploy.sh # publishes, then waits for /version.txt to match
```

`deploy.sh` ships only `index.html`, `main.js`, `worker.js`, `style.css` and the
two files in `pkg/` that the page loads. Each deploy is a new release, and
`deploy.sh` ships only `index.html`, `main.js`, `worker.js`, `style.css`, the
icons, the two store badges in `badges/`, and the two files in `pkg/` that the
page loads. Each deploy is a new release, and
`/version.txt` holds the commit it was built from (`-dirty` if the tree had
uncommitted changes). The site is static and needs no special headers.

Expand All @@ -46,6 +47,16 @@ Qwen 2.5 0.5B (GGUF, about 380 MB), once, on the first click of Download. It
is stored in the browser's Cache Storage for this origin, so a reload loads it
from disk without downloading again. **Remove model** in the footer deletes it.

## Phones and tablets

Loading the model peaks at about three times the file in memory (the cached
bytes, the copy handed to the engine, and the tensors built from it), so a bit
over 1 GB. Mobile browsers kill the tab before that. On phones and tablets the
page shows a warning instead of starting, with a link to Siti AI in the App
Store or Google Play (Onde in a native app) and a **Try anyway** button. The
same warning appears on any device whose previous visit was killed while the
model was loading. Lowering the peak is work for onde's `web_store`.

## Speed

Inference is CPU only, single threaded, using WebAssembly SIMD. Expect one to three
Expand Down
2 changes: 1 addition & 1 deletion examples/web-chat/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Build the wasm package into www/pkg. Serve www/ with any static server:
# python3 -m http.server -d www 8080
# Extra arguments go to `cargo`, e.g. a local onde while it is unreleased:
# Extra arguments go to `cargo`, e.g. a local onde checkout:
# ./build.sh --config 'patch.crates-io.onde.path="../../../onde"'
set -euo pipefail
cd "$(dirname "$0")"
Expand Down
3 changes: 2 additions & 1 deletion examples/web-chat/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ git diff --quiet HEAD -- . || version="$version-dirty"
# .gitignore from wasm-pack that have no place on the site.
stage="$(mktemp -d)"
trap 'rm -rf "$stage"' EXIT
mkdir "$stage/pkg"
mkdir "$stage/pkg" "$stage/badges"
cp www/index.html www/main.js www/worker.js www/style.css www/favicon.svg www/apple-touch-icon.png "$stage/"
cp www/badges/app-store.svg www/badges/google-play.png "$stage/badges/"
cp www/pkg/web_chat.js www/pkg/web_chat_bg.wasm "$stage/pkg/"
printf '%s\n' "$version" > "$stage/version.txt"
# Config only: the CLI reads it and leaves it out of the upload.
Expand Down
46 changes: 46 additions & 0 deletions examples/web-chat/www/badges/app-store.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/web-chat/www/badges/google-play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions examples/web-chat/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,50 @@ <h2>This browser can't run Ed</h2>
<p id="unsupported-reason"></p>
</section>

<section id="mobile" class="card" hidden>
<h2 id="mobile-title">Ed needs a desktop browser for now</h2>
<p id="mobile-reason"></p>
<p>
Open this page on a laptop or desktop in Chrome, Edge, Firefox or
Safari.
</p>
<div class="actions">
<button id="copy-link" type="button">Copy link</button>
</div>
<div class="promo">
<p>
Want this on your phone? <strong>Siti AI</strong> runs on Onde,
fully on-device.
</p>
<div class="store-badges">
<a
id="badge-app-store"
href="https://apps.apple.com/se/app/siti-ai/id6780047972"
rel="noopener"
><img
src="badges/app-store.svg"
alt="Download Siti AI on the App Store"
height="44"
loading="lazy"
/></a>
<a
id="badge-google-play"
href="https://play.google.com/store/apps/details?id=ai.siti.Siti"
rel="noopener"
><img
src="badges/google-play.png"
alt="Get Siti AI on Google Play"
height="44"
loading="lazy"
/></a>
</div>
<p class="more-apps">
<a href="https://5mb.app/" rel="noopener">More of our apps at 5mb.app</a>
</p>
</div>
<button id="try-anyway" type="button" class="link">Try anyway</button>
</section>

<section id="setup" class="card" hidden>
<h2 id="setup-title">Download the model</h2>
<p id="setup-text"></p>
Expand Down
Loading
Loading