# Introducing they're here: a site assistant that runs in your visitor's browser

| key | value |
| --- | --- |
| url | https://www.frobiovox.com/posts/2026/11/24/introducing-theyre-here-a-site-assistant-that-runs-in-your-visitors-browser/ |
| date | 2026-11-24 |
| tags | ai, browsers, web development, open source, frontpage |
| description | A proof of concept that replaces static-site search with a chat widget. It retrieves with Lunr and optionally lets Gemma write a cited answer on the visitor's own GPU. The live demo runs on static hosting with no application backend or hosted inference API. |


![Library card catalog drawers](/images/2026/10/31/card-catalogue-drawers.jpg)

*[Card catalogue drawers](https://commons.wikimedia.org/wiki/File:Card_catalogue_drawers.jpg) by Carolina Prysyazhnyuk, [CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/). Resized.*

Search on a static site is a bad deal. You can ship a JSON index and a search box that does keyword matching, or you can bolt on a hosted service that wants a monthly fee and a copy of your content. Meanwhile every other site now has a chat box that answers questions in sentences.

The obvious fix is a chatbot, and the obvious chatbot needs a backend, an API key, and a bill that grows with traffic. That's the exact set of things I picked a static site to avoid. I wrote about [why I care about that](/posts/2026/10/13/who-benefits-from-the-ai-guardrails/) recently. So I wanted to know whether the model could run on the visitor's machine instead.

It can, mostly. [They're here](https://gitlab.com/frob/theyrehere) is a proof of concept, and there's a [live demo](https://frob.gitlab.io/theyrehere/) you can try right now. The widget indexes your Markdown and shows relevant passages. A local [Gemma](https://huggingface.co/litert-community/gemma-4-E2B-it-litert-lm) model can use those passages to write an answer. The site uses static hosting for the page and its content. The browser fetches the runtime assets and can download model weights from Hugging Face. Search and inference run in the browser, with no application backend or hosted inference API.

## Three tags

Embed the widget with three tags and list the Markdown you want it to search in `content/manifest.json`. The widget is about 800 lines of vanilla JavaScript and has no build step.

```html
<link rel="stylesheet" href="assistant.css" />
<div id="llm-widget"></div>
<script src="assistant.js"></script>
```

It renders inline wherever the `div` is. I didn't want a floating button in the corner.

## How it works

1. **Index.** On load it fetches the Markdown sources listed in `content/manifest.json`, splits them by heading, and builds a [Lunr](https://lunrjs.com/) index. Fields are boosted: title x10, heading x5, tags and description x3, body x1.
2. **Retrieve.** A question runs a lexical search and returns the top four chunks. Retrieval works without WebGPU.
3. **Generate.** If you click **Load Gemma**, the widget downloads a model into the browser's OPFS and runs it over WebGPU. The retrieved chunks go into a RAG prompt and the answer streams back. Later visits can reuse the model while the browser retains it in local storage.
4. **Cite.** The widget shows the retrieved passages alongside the generated answer so you can check what supports it. Each passage links to its heading. Retrieval-only results include the same links.

I made the retrieval step stand on its own on purpose. A search that returns ranked, cited passages is useful with no model at all. Gemma only adds the prose on top. If WebGPU is missing, the widget hides **Load Gemma** and still shows retrieval results.

There's also a **Stats for nerds** disclosure under the input. It shows the runtime, the GPU adapter, model load time, time to first token and tokens per second. I wanted to see the cost, not guess at it.

## Two runtimes, because browsers

Running an LLM in a browser means choosing a runtime, and the choice depends on the browser.

- **LiteRT-LM** is the primary path when the browser supports WebGPU and WebAssembly JSPI.
- **MediaPipe Tasks GenAI** is the fallback when WebGPU is available and JSPI is missing.

I tested the demo in Firefox and Chrome on Arch Linux and macOS. Local generation should work in browsers with WebGPU. The widget checks for JSPI to choose a runtime.

On my Arch Linux setup, I used `--enable-unsafe-webgpu --use-vulkan` to get WebGPU working in Chromium, plus `--ozone-platform=x11` on Wayland. I checked `chrome://gpu` to confirm it was enabled. The README has the details, because that was the part that cost me an evening.

## Getting the model in

There are three ways to load it. The widget can stream it from Hugging Face. You can put the file next to the page and set `data-model-url`. Or you can click **Pick file** and select one from disk, which skips fetching and OPFS entirely. The default is Gemma 4 E2B. Pointing at E4B is a one-line change.

## What it isn't

It is a proof of concept, and the README says so at the top. The caveats, specifically:

- The first Gemma load requires a large model download unless you supply a local file. Most visitors won't want that for a blog search, so retrieval has to be good enough that the model is optional.
- A small local model will sometimes give a wrong answer. The citations are there so people can check, and you should expect to need them.
- The demo site is nine sample posts about WebGPU and on-device AI. That's easy retrieval. I haven't tried it on a messy real blog.

`SPEC.md` describes the planned Hugo module, with BM25F retrieval and an optional precomputed index for bigger sites. The MediaPipe fallback already exists in the proof of concept. The POC is where I'm finding out what the UI and the chunking should look like first.

To try it, open the [demo](https://frob.gitlab.io/theyrehere/). Ask it something, then click Load Gemma and ask again. The difference between the two answers is the whole experiment. If you'd rather run it yourself, `task run:poc` serves it on `localhost:8888`, or point `python3 -m http.server` at `poc/`. The demo is rebuilt from `poc/` on every push to the default branch, and there's nothing to build.

