Bead: Ollama Capabilities

**Bead** `70758adc-2d58-40f5-a294-443dfb255209` · [canonical URI](https://redfish.acequia.io/guerin/.agents/70758adc-2d58-40f5-a294-443dfb255209/) · discussion: Talk: Ollama Capabilities This page is the wiki facet of a [bead](https://redfish.acequia.io/guerin/.agents/); the bead is the source of truth.

## Identity - **URI:** https://redfish.acequia.io/guerin/.agents/70758adc-2d58-40f5-a294-443dfb255209/ - **GUID:** `70758adc-2d58-40f5-a294-443dfb255209` - **Slug:** ollama-capabilities - **Opened:** 2026-06-29 - **Access:** public (read:anonymous). No secrets — the harness runs against a *local* Ollama daemon; there is no cloud key.

## Motivation (why a GUID) Stephen has Ollama installed locally with **qwen2.5:3b** (text + tools) and **moondream** (vision). This bead captures a hands-on **capability harness** that exercises what a small local model can do — chat/streaming, tool calling, JSON-constrained output, vision, embeddings, raw completion, and Ollama's own perf counters — served from the home origin as a drop-in endpoint, with **no cloud dependency**. It is also a worked example of the **deploy-home `handler.mjs` convention** (the code lives at its serve location under `stephenguerin.live`, not inside the bead), mounting the recent beads that document how those hot-loaded handlers work.

## Mechanism (what this bead does) Holds the design notes + chat log. The deliverable code lives at its deploy home (per convention, like `/healthz` and `/photos`): - **[stephenguerin.live/ai/ollama/](c:/Users/steph/Documents/sites/stephenguerin.live/ai/ollama/)** - [`index.html`](c:/Users/steph/Documents/sites/stephenguerin.live/ai/ollama/index.html) — the capability harness UI (7 tabs: Models, Chat, Tools, JSON, Vision, Embeddings, Raw). - [`harness.mjs`](c:/Users/steph/Documents/sites/stephenguerin.live/ai/ollama/harness.mjs) — a dependency-free **browser** ES module: `OllamaHarness` (chat/generate/embed/similarity/tags/show), NDJSON stream consumer, perf-stat extractor, base64 image helper. - [`handler.mjs`](c:/Users/steph/Documents/sites/stephenguerin.live/ai/ollama/handler.mjs) — the deploy-home **server** module owning `/ai/ollama/*`: passthrough for the static demo + a **buffered same-origin proxy** to `127.0.0.1:11434`. - [`config.json`](c:/Users/steph/Documents/sites/stephenguerin.live/ai/ollama/config.json) — route descriptor (`static:false`). **Live:** http://127.0.0.1:3500/ai/ollama/ (home) · https://stephenguerin.live/ai/ollama/ (tunnel). ### The one design decision worth remembering The origin's filesystem router ends every handler response with `httpRes.end(body)` (body is a string/Buffer), so a `handler.mjs` **cannot stream tokens**. Therefore: - **Direct mode** (page on `localhost`): the browser talks straight to `localhost:11434` → **true token streaming**. Ollama's default `OLLAMA_ORIGINS` permits localhost on any port. - **Proxy mode** (page over the tunnel): the viewer can't reach the server's localhost, so `harness.mjs` falls back to the same-origin `./api/*` lane, which `handler.mjs` **buffers** (forces `stream:false` upstream) and returns whole. See [notes/01-handler-vs-harness-streaming.md](https://redfish.acequia.io/guerin/.agents/70758adc-2d58-40f5-a294-443dfb255209/2026-06-29/notes/01-handler-vs-harness-streaming.md).

## Folder Layout ``` 70758adc-.../ ├── about.md ├── session-namespace.json # mounts ├── uploads/ # inbound dock └── 2026-06-29/ ├── notes/00-ollama-capabilities.md ├── notes/01-handler-vs-harness-streaming.md └── chats/2026-06-29-ollama-capabilities.md ``` Code artifacts live at their deploy home (above), not in the bead.

## Mounts See [session-namespace.json](https://redfish.acequia.io/guerin/.agents/70758adc-2d58-40f5-a294-443dfb255209/session-namespace.json). - [`d3b7b28c` origin-routing](https://redfish.acequia.io/guerin/.agents/d3b7b28c-ed46-42c4-a5b1-fbd23129d665/about.md) — **the recent bead (2026-06-28) that ships a sibling `handler.mjs`** at `stephenguerin.live/healthz/`; same deploy-home pattern this bead follows. - [`06b7373f` photos-endpoint / filesystem-router](https://redfish.acequia.io/guerin/.agents/06b7373f-2ba9-46c5-88bb-31bd93ce453f/about.md) — defines the hot-loaded `handle(req, ctx)` contract (deepest `handler.mjs` wins, mtime cache-bust). The `/photos` handler is the worked example I modeled the proxy on. - [`82bd6fa4` router-bead (Hubler runtime)](https://redfish.acequia.io/guerin/.agents/82bd6fa4-4d5a-435b-9deb-ca930a82aa89/about.md) — the canonical `handler.mjs` and the `server.js` that hot-loads all of this; cognition rung 0, no live LLM in the handler.

## Session Log - **2026-06-29** — Opened. Verified the local Ollama API (qwen2.5:3b chat/tools/JSON-schema ✓, moondream vision ✓, embeddings correctly unsupported by the two installed models). Built the harness + handler, confirmed both the static passthrough and the proxy lanes live on port 3500 with zero restart (mtime hot-load).

## Modus Operandi Anonymous read. Open the harness, pick a tab, run it. Extend via [uploads/](https://redfish.acequia.io/guerin/.agents/70758adc-2d58-40f5-a294-443dfb255209/uploads/).

## Capabilities / status - **Built & verified:** Models census, streaming chat, tool round-trip, JSON-schema extraction, vision (moondream), raw generate, perf counters; buffered same-origin proxy. - **Gated on a model pull:** Embeddings tab — neither installed model has the `embedding` capability; the tab self-detects and shows `ollama pull nomic-embed-text`.

## Lifecycle Active demo bead; apoptotic. The code is the live endpoint; the bead is its provenance + design record.

## Limitations - Streaming only in direct (localhost) mode; proxy mode is buffered by the router contract. - The proxy forwards only an explicit allowlist of `/api/*` paths (no arbitrary upstream). - `get_weather` in the Tools tab is a deterministic mock (no network), so the tool round-trip is fully local.

## References (bead cross-links) - Bead: Origin Routing · [canonical](https://redfish.acequia.io/guerin/.agents/d3b7b28c-ed46-42c4-a5b1-fbd23129d665/) - Bead: Android Photo Sync · [canonical](https://redfish.acequia.io/guerin/.agents/06b7373f-2ba9-46c5-88bb-31bd93ce453f/) - Bead: Stephenguerin.live Router Bead · [canonical](https://redfish.acequia.io/guerin/.agents/82bd6fa4-4d5a-435b-9deb-ca930a82aa89/)

See all: Beads