@hackbuild/ai-views 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -80
- package/dist/chat.d.ts +18 -2
- package/dist/chat.js +7 -1
- package/dist/elements.d.ts +6 -0
- package/dist/frame.d.ts +2 -0
- package/dist/jobs.d.ts +6 -1
- package/dist/jobs.js +4 -1
- package/dist/memory.d.ts +9 -0
- package/dist/memory.js +3 -0
- package/dist/mount-chat.d.ts +4 -1
- package/dist/mount-chat.js +2 -1
- package/dist/mount-frame.d.ts +13 -1
- package/dist/mount-frame.js +3 -1
- package/dist/mount-mask.d.ts +19 -1
- package/dist/mount-mask.js +5 -1
- package/dist/mount-model.d.ts +1 -0
- package/dist/mount-transcribe.d.ts +11 -2
- package/dist/mount-transcribe.js +2 -2
- package/dist/pick.d.ts +17 -0
- package/dist/pick.js +6 -0
- package/dist/rows.d.ts +6 -0
- package/dist/rows.js +2 -0
- package/dist/single/elements.iife.js +81 -50
- package/dist/single/elements.js +81 -50
- package/dist/single/index.iife.js +74 -45
- package/dist/single/index.js +74 -45
- package/dist/single/vue.iife.js +87 -45
- package/dist/single/vue.js +88 -45
- package/dist/transcribe.d.ts +14 -2
- package/dist/transcribe.js +2 -2
- package/dist/vue.d.ts +22 -0
- package/dist/vue.js +22 -0
- package/llms.md +1133 -0
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -1,93 +1,241 @@
|
|
|
1
1
|
# @hackbuild/ai-views
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
3
|
+
Put a model picker, a chat, a transcriber, a mask studio or a camera frame on your page, drawn with the hackbuild-ui stylesheet, as custom elements or Vue components.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@hackbuild/ai-views) [](../../LICENSE)  
|
|
6
|
+
|
|
7
|
+
Browser status: no model run of this package has been verified in a real browser yet.
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
- Gives each job (chat, speech to text, vision, detector, masks, image, voice, depth, embed, face swap, landmarks) a model picker whose rows say whether a model fits this machine and why not.
|
|
12
|
+
- Keeps the state behind every view in node safe objects: a pick, a jobs rack, a chat thread and list, a transcribe queue.
|
|
13
|
+
- Draws the views in light DOM with the page's hackbuild-ui stylesheet and never styles locally.
|
|
14
|
+
- Ships every view as a mount function, a custom element and a Vue 3 component, all on one code path.
|
|
15
|
+
- Replaces @hackbuild/ai-elements.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install @hackbuild/ai-views @virgilvox/hackbuild-ui
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
@virgilvox/hackbuild-ui is a required peer; the page also loads its stylesheet. Vue is an optional peer, needed only for the `/vue` entry.
|
|
24
|
+
|
|
25
|
+
| subpath | runtime | pin |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `.` | none; node safe state | none |
|
|
28
|
+
| `./elements` | @virgilvox/hackbuild-ui (peer) | `>=0.10.0 <0.11.0` |
|
|
29
|
+
| `./vue` | vue (optional peer) and @virgilvox/hackbuild-ui | vue `^3.4.0` |
|
|
30
|
+
|
|
31
|
+
Model runtimes are never imported here. A picker loads only through the loader you pass, such as `weightsLoader(store)` or your own that starts a runtime.
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { importEsm } from "@hackbuild/ai-env";
|
|
37
|
+
import { ALL_RECORDS, chatThread, useModelPick, weightsLoader } from "@hackbuild/ai-views";
|
|
38
|
+
import { mountChatPane, mountComposer, mountModelSelect } from "@hackbuild/ai-views/elements";
|
|
39
|
+
import { loadWllama, wllamaUrls, type WllamaModule } from "@hackbuild/chat/wllama";
|
|
40
|
+
import { openWeightStore } from "@hackbuild/weights";
|
|
41
|
+
|
|
42
|
+
// a chat picker over the GGUF rows, files through the weight store; Qwen2.5 0.5B Instruct weights are Apache-2.0
|
|
43
|
+
const fetchFiles = weightsLoader(await openWeightStore());
|
|
44
|
+
const wllama = await importEsm<WllamaModule>(wllamaUrls().esm); // the runtime is passed in, never bundled
|
|
45
|
+
const thread = chatThread({ system: "answer in one line." });
|
|
46
|
+
const pick = useModelPick("chat", {
|
|
47
|
+
records: ALL_RECORDS.filter((r) => r.provider === "wllama"), chosen: "qwen2.5-0.5b-instruct-gguf",
|
|
48
|
+
loader: async (rec, ctx) => thread.setEngine(await loadWllama({ module: wllama, blobs: [...((await fetchFiles(rec, ctx)) as Map<string, Blob>).values()] })),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// the picker, the turns and the composer, drawn with the page's hackbuild-ui stylesheet
|
|
52
|
+
mountModelSelect(document.querySelector<HTMLElement>("#model")!, pick);
|
|
53
|
+
mountChatPane(document.querySelector<HTMLElement>("#chat")!, thread);
|
|
54
|
+
mountComposer(document.querySelector<HTMLElement>("#composer")!, thread);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Live example
|
|
58
|
+
|
|
59
|
+
The view demo pages run every view on stub providers with no weights: [hackbuild-browser-ai/views](https://hackbuild.github.io/hackbuild-browser-ai/views/). The package page is at [hackbuild-browser-ai/ai-views](https://hackbuild.github.io/hackbuild-browser-ai/ai-views/).
|
|
60
|
+
|
|
61
|
+
## Concepts
|
|
62
|
+
|
|
63
|
+
### three entries
|
|
64
|
+
|
|
65
|
+
`@hackbuild/ai-views` is node safe: `JOBS`, `jobRecords(job)`, `rowOf` (a record as a hackbuild-ui ModelRow), `useModelPick(job)`, `useJobsPick(jobs, presets)`, `weightsLoader(store)`, `weightsRemover(store)`, `defaultPick`, `chatThread`, `chatList`, `contextSegments`, `transcribeQueue`, the frame geometry and `traceRows`. `@hackbuild/ai-views/elements` holds the mount functions and `define()`. `@hackbuild/ai-views/vue` holds `ModelSelect`, `ModelJobs`, `ChatPane`, `Composer`, `ChatList`, `ContextMeter`, `MemoryInspector`, `TranscribeDrop`, `TranscriptView`, `TranscribeQueue`, `MaskStudio`, `MaskTools`, `MaskVerbs`, `MaskRack`, `FrameView` and `CameraFeed`; only this entry imports Vue.
|
|
66
|
+
|
|
67
|
+
### custom elements
|
|
68
|
+
|
|
69
|
+
Nothing registers on import. `define()` registers the elements bare, and `define("hb")` gives `<hb-model-select>` and so on; names already defined are left alone. Each element carries `.hb-view` (display contents), so a layout region of hackbuild-ui places its parts. A `for` attribute names the element whose state a part binds to:
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<model-select job="chat" variant="chip"></model-select>
|
|
73
|
+
<chat-pane id="chat"></chat-pane> <chat-composer for="chat"></chat-composer>
|
|
74
|
+
<transcribe-drop id="t"></transcribe-drop> <transcript-exports for="t"></transcript-exports>
|
|
75
|
+
<mask-studio id="m"></mask-studio> <mask-tools for="m"></mask-tools>
|
|
76
|
+
<frame-view id="f"></frame-view> <camera-feed for="f"></camera-feed>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Set `engine` on `<chat-pane>` to a @hackbuild/chat engine, or `pick`, `env`, `loader` and `records` on `<model-select>`. `<model-select>` fires `choose`, then `loaded` and `failed` once per load.
|
|
80
|
+
|
|
81
|
+
### vue
|
|
82
|
+
|
|
83
|
+
Each component mounts the same function the custom element does, on a host that shows as `.hb-view`; props in, events out. `ModelSelect` emits `pick`, `choose`, `loaded` and `failed`; `MaskStudio` emits `studio`, `FrameView` emits `view` and `CameraFeed` emits `feed` and `frame`, each handing over the mounted object.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { ModelSelect, ChatPane, Composer } from "@hackbuild/ai-views/vue";
|
|
87
|
+
import { chatThread } from "@hackbuild/ai-views";
|
|
88
|
+
const thread = chatThread({ engine });
|
|
89
|
+
// <ModelSelect job="chat" variant="chip" /> <ChatPane :thread="thread" /> <Composer :thread="thread" />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### picks and loaders
|
|
93
|
+
|
|
94
|
+
A pick loads only through its loader (none is an error the row shows), runs it for every row, a no download row included, and keeps its result on `snapshot().loaded`; `remove()` deletes through `onRemove`. It starts on the first "start here" record that fits, else the first fast or steady one. `weightsLoader(store)` fetches a record's files through @hackbuild/weights; a record that loads through its runtime (WebLLM, MediaPipe and the like) needs a loader from the page. `useJobsPick` joins pickers as a rack with a line per job, presets with their download totals, and load all.
|
|
95
|
+
|
|
96
|
+
### views
|
|
97
|
+
|
|
98
|
+
| view | element | what it does |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| ModelSelect | `<model-select job variant go>` | one line with the choice and one pink "load, size"; the bar chip; a sheet with search, the fits, uncensored and no download filters, groups, the row detail and the "your own" forms. `<model-jobs jobs>` (properties `env`, `loader`, `records`, `presets`) gives a line per job, presets with totals and "load all" |
|
|
101
|
+
| ChatPane, Composer | `<chat-pane>`, `<chat-composer for>`, `<chat-list for>`, `<chat-context for budget>` | the thread, reasoning in a fold, memory used per reply, copy and redo on the last reply; the chats list (new, open, rename, delete) and the context meter; Enter sends, Shift Enter adds a line, Escape stops |
|
|
102
|
+
| TranscribeDrop, TranscriptView | `<transcribe-drop>`, `<transcript-view for>`, `<transcribe-queue for>`, `<transcript-exports for>` | the drop zone becomes the transcript; a queue of files; lines with their time, edit in place with undo; txt, srt, vtt, json |
|
|
103
|
+
| MaskStudio | `<mask-studio>`, `<mask-tools for>`, `<mask-verbs for>`, `<mask-rack for part>` | click segment, wand, brush, eraser, lasso, polygon, rectangle, ellipse, flood, pan (the hackbuild-ui mask editor's tools), segment everything, smooth, expand, shrink, saved masks, undo, zoom; `mask()` gives ImageData and `exportAs()` a png Blob |
|
|
104
|
+
| FrameView, CameraFeed | `<frame-view>`, `<camera-feed for>` | boxes with word and score, landmarks, a count and the caption over a frame; the camera at a set rate |
|
|
105
|
+
| memory inspector | `<memory-inspector>` | one row per fused recall candidate, the used ones marked |
|
|
106
|
+
|
|
107
|
+
### jobs and records
|
|
108
|
+
|
|
109
|
+
Jobs and their records: chat (the chat rows of the @hackbuild/models catalogue), speech to text (six records), vision language (SmolVLM 256M and 500M, SmolVLM2 256M video, LFM2-VL 450M, Gemma 4 E2B), detector (EfficientDet lite0, YOLOv10 n, s and m), masks (SlimSAM, FastSAM-s), image (SD-Turbo, SD 1.5, and SDXL-Turbo greyed as not run yet), voice (Kokoro, Pocket TTS, the vocal tract, the system voice), depth, embed, landmarks and face swap (scrfd, ArcFace, inswapper). The records come from the packages that run them; a record listed in more than one place counts once. Every record carries its weight licence; the non commercial ones are marked in the picker.
|
|
110
|
+
|
|
111
|
+
## API overview
|
|
112
|
+
|
|
113
|
+
| export | what it does |
|
|
114
|
+
|---|---|
|
|
115
|
+
| [`useModelPick`](../../docs/api/ai-views/index.md#usemodelpick) | a model picker for one job |
|
|
116
|
+
| [`useJobsPick`](../../docs/api/ai-views/index.md#usejobspick) | pickers for several jobs as one rack |
|
|
117
|
+
| [`weightsLoader`](../../docs/api/ai-views/index.md#weightsloader) | a loader that fetches files through a weight store |
|
|
118
|
+
| [`chatThread`](../../docs/api/ai-views/index.md#chatthread) | a chat thread over an engine |
|
|
119
|
+
| [`chatList`](../../docs/api/ai-views/index.md#chatlist) | several chats, one open |
|
|
120
|
+
| [`transcribeQueue`](../../docs/api/ai-views/index.md#transcribequeue) | a queue of files to transcribe, with edits and exports |
|
|
121
|
+
| [`JOBS`](../../docs/api/ai-views/index.md#jobs) | every job's words and capability test |
|
|
122
|
+
| [`ALL_RECORDS`](../../docs/api/ai-views/index.md#all_records) | every record the views know |
|
|
123
|
+
| [`rowOf`](../../docs/api/ai-views/index.md#rowof) | a record as one picker row |
|
|
124
|
+
| [`define`](../../docs/api/ai-views/elements.md#define) | register the custom elements |
|
|
125
|
+
| [`mountModelSelect`](../../docs/api/ai-views/elements.md#mountmodelselect) | the picker on a host |
|
|
126
|
+
| [`mountChatPane`](../../docs/api/ai-views/elements.md#mountchatpane), [`mountComposer`](../../docs/api/ai-views/elements.md#mountcomposer) | the turns and the message box |
|
|
127
|
+
| [`mountTranscribeDrop`](../../docs/api/ai-views/elements.md#mounttranscribedrop) | the drop zone that becomes the transcript |
|
|
128
|
+
| [`mountMaskStudio`](../../docs/api/ai-views/elements.md#mountmaskstudio) | the mask studio |
|
|
129
|
+
| [`mountFrameView`](../../docs/api/ai-views/elements.md#mountframeview), [`mountCameraFeed`](../../docs/api/ai-views/elements.md#mountcamerafeed) | a frame with results drawn over it, and the camera |
|
|
130
|
+
| [`ModelSelect`](../../docs/api/ai-views/vue.md#modelselect), [`ChatPane`](../../docs/api/ai-views/vue.md#chatpane) and the other components | the views as Vue components |
|
|
131
|
+
|
|
132
|
+
The full reference is in [docs/api/ai-views](../../docs/api/ai-views/README.md).
|
|
133
|
+
|
|
134
|
+
## Models and weights
|
|
135
|
+
|
|
136
|
+
This package runs no model; it lists records and loads them through the loader you pass. Weights are never bundled; `weightsLoader(store)` fetches them from the host in the table and @hackbuild/weights caches them. The 40 chat records are listed in [@hackbuild/models](../models/README.md#models-and-weights). Sizes are MiB of download; the source word is in each cell. Licences are as recorded on each record; several are non commercial or AGPL-3.0, and the picker marks them.
|
|
137
|
+
|
|
138
|
+
| model | id | size, MiB (source word in the cell) | licence | loads from |
|
|
139
|
+
|---|---|---|---|---|
|
|
140
|
+
| whisper large-v3-turbo | `whisper-large-v3-turbo` | 1534 (vendor) | MIT | Hugging Face `onnx-community/whisper-large-v3-turbo`, transformers.js |
|
|
141
|
+
| whisper base | `whisper-base` | 77 (vendor) | MIT | Hugging Face `onnx-community/whisper-base`, transformers.js |
|
|
142
|
+
| whisper small.en | `whisper-small.en` | 238 (vendor) | MIT (the OpenAI Whisper release; the Xenova ONNX card says apache-2.0) | Hugging Face `Xenova/whisper-small.en`, transformers.js |
|
|
143
|
+
| whisper base.en | `whisper-base.en` | 90 (inferred) | MIT (the OpenAI Whisper release; the Xenova ONNX card says apache-2.0) | Hugging Face `Xenova/whisper-base.en`, transformers.js |
|
|
144
|
+
| whisper tiny.en | `whisper-tiny.en` | 39 (vendor) | MIT (the OpenAI Whisper release; the Xenova ONNX card says apache-2.0) | Hugging Face `Xenova/whisper-tiny.en`, transformers.js |
|
|
145
|
+
| moonshine base | `moonshine-base` | 60 (vendor) | MIT (english models, per the model card; check before use) | Hugging Face `onnx-community/moonshine-base-ONNX`, transformers.js |
|
|
146
|
+
| depth anything v2 small | `depth-anything-v2-small` | 100 (inferred) | Apache-2.0 | Hugging Face `onnx-community/depth-anything-v2-small`, transformers.js |
|
|
147
|
+
| mediapipe efficientdet lite0 (coco, 80 classes) | `efficientdet-lite0` | 7 (inferred) | Apache-2.0 | `storage.googleapis.com`, MediaPipe |
|
|
148
|
+
| mediapipe selfie segmenter | `selfie-segmenter` | 1 (inferred) | Apache-2.0 | `storage.googleapis.com`, MediaPipe |
|
|
149
|
+
| mediapipe face landmarker with blendshapes | `face-landmarker` | 4 (inferred) | Apache-2.0 | `storage.googleapis.com`, MediaPipe |
|
|
150
|
+
| mediapipe hand landmarker | `hand-landmarker` | 8 (inferred) | Apache-2.0 | `storage.googleapis.com`, MediaPipe |
|
|
151
|
+
| mediapipe gesture recognizer (7 canned gestures) | `gesture-recognizer` | 8 (inferred) | unknown, check the mediapipe model card | `storage.googleapis.com`, MediaPipe |
|
|
152
|
+
| mediapipe pose landmarker lite | `pose-landmarker-lite` | 6 (inferred) | Apache-2.0 | `storage.googleapis.com`, MediaPipe |
|
|
153
|
+
| slimsam 77 uniform (point prompts) | `slimsam-77-uniform` | 38 (vendor) | Apache-2.0 | Hugging Face `Xenova/slimsam-77-uniform`, transformers.js |
|
|
154
|
+
| smolvlm 256m | `smolvlm-256m-instruct` | 260 (inferred) | Apache-2.0 | Hugging Face `HuggingFaceTB/SmolVLM-256M-Instruct`, transformers.js |
|
|
155
|
+
| lfm2-vl 450m | `lfm2-vl-450m` | 320 (inferred) | LFM Open License v1.0 | Hugging Face `onnx-community/LFM2-VL-450M-ONNX`, transformers.js |
|
|
156
|
+
| smolvlm 500m | `smolvlm-500m-instruct` | 463 (vendor) | Apache-2.0 | Hugging Face `HuggingFaceTB/SmolVLM-500M-Instruct`, transformers.js |
|
|
157
|
+
| smolvlm2 256m video | `smolvlm2-256m-video-instruct` | 252 (vendor) | Apache-2.0 | Hugging Face `HuggingFaceTB/SmolVLM2-256M-Video-Instruct`, transformers.js |
|
|
158
|
+
| depth anything v2 base | `depth-anything-v2-base` | 186 (vendor) | CC-BY-NC-4.0 (the model card's licence field) | Hugging Face `onnx-community/depth-anything-v2-base`, transformers.js |
|
|
159
|
+
| depth anything v1 small | `depth-anything-small-v1` | 48 (vendor) | Apache-2.0 (the upstream card; this export's card has no licence field) | Hugging Face `Xenova/depth-anything-small-hf`, transformers.js |
|
|
160
|
+
| gemma 4 e2b | `gemma-4-e2b-vision` | 3566 (vendor) | Apache-2.0 (the model card's licence field) | Hugging Face `onnx-community/gemma-4-E2B-it-ONNX`, transformers.js |
|
|
161
|
+
| yolov10 nano | `yolov10n` | 9 (vendor) | AGPL-3.0 (Ultralytics weights, the model card's licence field) | Hugging Face `onnx-community/yolov10n`, `onnx/model.onnx`, onnxruntime-web |
|
|
162
|
+
| yolov10 small | `yolov10s` | 28 (vendor) | AGPL-3.0 (Ultralytics weights, the model card's licence field) | Hugging Face `onnx-community/yolov10s`, `onnx/model.onnx`, onnxruntime-web |
|
|
163
|
+
| yolov10 medium | `yolov10m` | 59 (vendor) | AGPL-3.0 (Ultralytics weights, the model card's licence field) | Hugging Face `onnx-community/yolov10m`, `onnx/model.onnx`, onnxruntime-web |
|
|
164
|
+
| fastsam s | `fastsam-s` | 45 (vendor) | AGPL-3.0 upstream (Ultralytics FastSAM); the export's card says apache-2.0 | Hugging Face `anakhiu/fastsam-onnx`, `fastsam_s.onnx`, onnxruntime-web |
|
|
165
|
+
| face finder (scrfd 10g) | `scrfd-10g` | 16 (vendor) | InsightFace model pack: non-commercial research only (the buffalo_l pack terms) | Hugging Face `immich-app/buffalo_l`, `detection/model.onnx`, onnxruntime-web |
|
|
166
|
+
| face id (arcface r50) | `arcface-w600k-r50` | 166 (vendor) | InsightFace model pack: non-commercial research only (the buffalo_l pack terms) | Hugging Face `immich-app/buffalo_l`, `recognition/model.onnx`, onnxruntime-web |
|
|
167
|
+
| face swap (inswapper 128) | `inswapper-128` | 529 (vendor) | InsightFace: non-commercial research only; the mirror's card says gpl-3.0 | Hugging Face `hacksider/inswapper_128`, `inswapper_128.onnx`, onnxruntime-web |
|
|
168
|
+
| kokoro 82m | `kokoro-82m` | 310 (vendor) | Apache-2.0 (weights); the kokoro-js runtime phonemizes with eSpeak NG, GPL-3.0-or-later, loaded at run time and opt in | Hugging Face `onnx-community/Kokoro-82M-v1.0-ONNX`, kokoro-js |
|
|
169
|
+
| pocket tts | `pocket-tts` | 189 (inferred) | CC-BY-4.0 (weights), MIT (code) | Hugging Face `kyutai/pocket-tts`, the Pocket TTS worker |
|
|
170
|
+
| bellows voice | `bellows-voice` | 0 (vendor) | none, no weights (code MIT) | nothing to download, the vocal tract code |
|
|
171
|
+
| system voice | `web-speech` | 0 (vendor) | system voices, the platform's terms | nothing to download, the system voice |
|
|
172
|
+
| sd-turbo 512 | `sd-turbo` | 2397 (vendor) | Stability AI Non-Commercial Research Community License (the LICENSE in schmuell/sd-turbo-ort-web; upstream stabilityai/sd-turbo moved to the Community License in July 2024, this export did not) | Hugging Face `schmuell/sd-turbo-ort-web`, onnxruntime-web |
|
|
173
|
+
| stable diffusion 1.5 | `sd-1.5` | 1969 (vendor) | CreativeML OpenRAIL-M (use restrictions in its attachment A) | Hugging Face `microsoft/stable-diffusion-v1.5-webnn`, onnxruntime-web |
|
|
174
|
+
| sdxl-turbo 512 (listed, not run yet) | `sdxl-turbo` | 2548 (vendor) | Stability AI Community License (named in the card text; the repo has no licence field) | Hugging Face `webnn/sdxl-turbo`, onnxruntime-web |
|
|
175
|
+
| potion base 8M (static) | `potion-base-8m` | 30 (inferred) | MIT | Hugging Face `minishlab/potion-base-8M`, the static embedder |
|
|
176
|
+
| all-MiniLM-L6-v2 | `minilm-l6` | 23 (inferred) | Apache-2.0 | Hugging Face `Xenova/all-MiniLM-L6-v2`, transformers.js |
|
|
177
|
+
| bge-small-en-v1.5 | `bge-small-en` | 32 (vendor) | MIT | Hugging Face `Xenova/bge-small-en-v1.5`, transformers.js |
|
|
178
|
+
| face-api tiny landmarks (68 points) | `face-api-tiny` | 1 (inferred) | MIT | `cdn.jsdelivr.net`, face-api |
|
|
179
|
+
| all-minilm-l6-v2 | `all-minilm-l6-v2` | 23 (inferred) | Apache-2.0 | Hugging Face `Xenova/all-MiniLM-L6-v2`, transformers.js |
|
|
180
|
+
| htdemucs-fast | `htdemucs-fast` | 166 (inferred) | MIT | Hugging Face `StemSplitio/htdemucs-onnx`, `htdemucs_fp16weights.onnx`, onnxruntime-web |
|
|
181
|
+
|
|
182
|
+
## Browser support
|
|
183
|
+
|
|
184
|
+
| feature | needs | Chrome | Safari | Firefox | phone |
|
|
185
|
+
|---|---|---|---|---|---|
|
|
186
|
+
| state (`.` entry) | nothing | yes (inferred) | yes (inferred) | yes (inferred) | yes (inferred) |
|
|
187
|
+
| custom elements | `customElements` | yes (measured, headless) | yes (inferred) | yes (inferred) | yes (inferred) |
|
|
188
|
+
| Vue components | Vue 3.4 or later | yes (inferred) | yes (inferred) | yes (inferred) | yes (inferred) |
|
|
189
|
+
| CameraFeed | `getUserMedia` on a secure page | unknown | unknown | unknown | unknown |
|
|
190
|
+
| mask drawing by touch | pointer events | unknown | unknown | unknown | unknown |
|
|
191
|
+
|
|
192
|
+
No WebGPU or wasm here; the model you load brings its own needs, and its row says when it cannot run. The headless smoke runs the demo pages on stub providers; no real model has run through a view (see below).
|
|
193
|
+
|
|
194
|
+
## Errors and troubleshooting
|
|
195
|
+
|
|
196
|
+
| message | cause | what to do |
|
|
197
|
+
|---|---|---|
|
|
198
|
+
| `no loader for <id>: pass one to useModelPick, such as weightsLoader(store)` | a pick has no loader | pass `loader` to `useModelPick`, or set `loader` on `<model-select>` |
|
|
199
|
+
| `<model> loads through its runtime. the page passes a loader for it.` | `weightsLoader` got a record with no files to fetch (WebLLM, MediaPipe and the like) | pass a loader that starts that runtime |
|
|
200
|
+
| `this needs a model. pick one in the bar and load it.` (a reply, `NO_ENGINE`) | the thread has no engine | load a model and call `thread.setEngine`, or set `engine` on `<chat-pane>` |
|
|
201
|
+
| `no speech model loaded. pick one and load it.` (a failed file) | `<transcribe-drop>` has no transcriber | set its transcriber from @hackbuild/transcribe |
|
|
202
|
+
| `no custom elements in this environment` | `define()` ran without `customElements` or `HTMLElement` | call it on a page, or pass a registry and a base class |
|
|
203
|
+
| `the image did not load: ...`, `the cut failed: ...`, `segment everything failed: ...` (studio state) | the image or a segment model failed | read the message; check the model loaded |
|
|
204
|
+
|
|
205
|
+
## Works with
|
|
206
|
+
|
|
207
|
+
- [@hackbuild/models](../models/README.md) supplies the records, fit words and budget behind every picker row.
|
|
208
|
+
- [@hackbuild/weights](../weights/README.md) fetches and caches the files through `weightsLoader(store)` and deletes them through `weightsRemover(store)`.
|
|
209
|
+
- [@hackbuild/chat](../chat/README.md) gives the engine a chat thread streams from.
|
|
210
|
+
- [@hackbuild/transcribe](../transcribe/README.md) gives the transcriber a transcribe queue runs, and the txt, srt, vtt and json writers.
|
|
211
|
+
- [@hackbuild/memory](../memory/README.md) gives the recall the memory inspector shows.
|
|
212
|
+
- [@hackbuild/vision](../vision/README.md), [@hackbuild/speak](../speak/README.md), [@hackbuild/embed](../embed/README.md) and [@hackbuild/imagegen](../imagegen/README.md) supply the records of their jobs.
|
|
213
|
+
|
|
214
|
+
## Changelog and licences
|
|
215
|
+
|
|
216
|
+
Changes are in the repository [CHANGELOG](../../CHANGELOG.md). Code is MIT ([LICENSE](../../LICENSE)); this README is CC-BY-4.0 with its code samples also MIT. No weights ship here. Each record names its weight licence in the table above, among them Apache-2.0, MIT, CC-BY-NC-4.0, AGPL-3.0 (YOLOv10, FastSAM), the InsightFace non-commercial research terms, the Stability AI licences and CreativeML OpenRAIL-M. The quick start loads Qwen2.5 0.5B Instruct GGUF, weights Apache-2.0.
|
|
69
217
|
|
|
70
218
|
## What is verified, and what is not
|
|
71
219
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
|
|
220
|
+
### Verified on this machine
|
|
221
|
+
|
|
222
|
+
| date | check | result |
|
|
223
|
+
|---|---|---|
|
|
224
|
+
| 2026-11-25 | `npx vitest run packages/ai-views` | pass: every job has the records above with a speed word and a verdict; rows carry size, memory, backend, marks, detail and options, and a row that does not fit names why; a pick loads with progress, cancels and keeps a failure's words; presets total their download; the chat thread streams with the reasoning apart and memory used; the queue runs, edits with undo and exports; the frame mapping crops and mirrors; define registers every element |
|
|
225
|
+
| 2026-11-25 | `node tools/smoke-views.mjs`, headless | pass: one smoke per demo page on stub providers with no weights |
|
|
226
|
+
|
|
227
|
+
### Not verified by anything
|
|
228
|
+
|
|
229
|
+
- A real model through any view in this package (the demos use stubs).
|
|
230
|
+
- Touch drawing on a phone.
|
|
231
|
+
- Screen readers.
|
|
84
232
|
|
|
85
233
|
## Size budget
|
|
86
234
|
|
|
87
235
|
| file | gzip (measured) | ceiling |
|
|
88
236
|
|---|---|---|
|
|
89
|
-
| `dist/index.js` (main entry, imports external) | 12,
|
|
90
|
-
| `dist/single/elements.iife.js` (single file build) |
|
|
237
|
+
| `dist/index.js` (main entry, imports external) | 12,413 bytes | 13,033 bytes |
|
|
238
|
+
| `dist/single/elements.iife.js` (single file build) | 86,649 bytes | 90,981 bytes |
|
|
91
239
|
|
|
92
240
|
Measured 2026-11-25 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
|
|
93
241
|
tarball. Generated from `tools/size-budget.json`; CI fails when a file moves more than
|
package/dist/chat.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The state behind ChatPane and Composer
|
|
2
|
+
* The state behind ChatPane and Composer: a
|
|
3
3
|
* thread of turns, one live reply streamed from a @hackbuild/chat engine
|
|
4
4
|
* with its reasoning kept apart for the think fold, the memory each reply
|
|
5
5
|
* used, stop, regenerate, and a markdown export. Framework free.
|
|
6
6
|
*/
|
|
7
7
|
import type { ChatEngine } from "@hackbuild/chat";
|
|
8
|
+
/** A memory recalled for a reply, with its label and score. */
|
|
8
9
|
export interface MemoryUsed {
|
|
9
10
|
label: string;
|
|
10
11
|
/** 0 to 1, shown beside the label. */
|
|
11
12
|
score?: number;
|
|
12
13
|
}
|
|
14
|
+
/** One chat turn: role, text, reasoning, time, whether it is done, memory used, stats and a note. */
|
|
13
15
|
export interface Turn {
|
|
14
16
|
id: number;
|
|
15
17
|
role: "user" | "assistant";
|
|
@@ -25,12 +27,17 @@ export interface Turn {
|
|
|
25
27
|
/** "stopped", "failed: ...". */
|
|
26
28
|
note?: string;
|
|
27
29
|
}
|
|
30
|
+
/** What a thread shows: its turns, whether a reply streams, and whether an engine is set. */
|
|
28
31
|
export interface ThreadSnapshot {
|
|
29
32
|
turns: readonly Turn[];
|
|
30
33
|
busy: boolean;
|
|
31
34
|
/** An engine is set; without one a reply says how to get one. */
|
|
32
35
|
ready: boolean;
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for `chatThread` and `chatList`: engine, system prompt, memory recall, the no engine
|
|
39
|
+
* reply, clock and reply token cap.
|
|
40
|
+
*/
|
|
34
41
|
export interface ThreadOptions {
|
|
35
42
|
engine?: ChatEngine | null;
|
|
36
43
|
system?: string;
|
|
@@ -42,6 +49,7 @@ export interface ThreadOptions {
|
|
|
42
49
|
/** Reply token cap. */
|
|
43
50
|
maxTokens?: number;
|
|
44
51
|
}
|
|
52
|
+
/** A chat thread: send, stop, regenerate, remove and clear turns, set the engine, and export as markdown. */
|
|
45
53
|
export interface ChatThread {
|
|
46
54
|
snapshot(): ThreadSnapshot;
|
|
47
55
|
subscribe(fn: (s: ThreadSnapshot) => void): () => void;
|
|
@@ -55,20 +63,24 @@ export interface ChatThread {
|
|
|
55
63
|
/** The thread as markdown, for an export. */
|
|
56
64
|
markdown(title?: string): string;
|
|
57
65
|
}
|
|
66
|
+
/** What a reply says when no chat engine is set. */
|
|
58
67
|
export declare const NO_ENGINE = "this needs a model. pick one in the bar and load it.";
|
|
68
|
+
/** Creates a chat thread that streams replies from an engine, with optional memory recall per message. */
|
|
59
69
|
export declare function chatThread(o?: ThreadOptions): ChatThread;
|
|
70
|
+
/** One chat in a chat list: id, title, last update and turn count. */
|
|
60
71
|
export interface ChatListItem {
|
|
61
72
|
id: string;
|
|
62
73
|
title: string;
|
|
63
74
|
updated: number;
|
|
64
75
|
count: number;
|
|
65
76
|
}
|
|
77
|
+
/** The chats of a list, newest first, and the id of the open one. */
|
|
66
78
|
export interface ChatListSnapshot {
|
|
67
79
|
items: readonly ChatListItem[];
|
|
68
80
|
current: string;
|
|
69
81
|
}
|
|
70
82
|
/**
|
|
71
|
-
* Several chats
|
|
83
|
+
* Several chats: a list with the newest first, one
|
|
72
84
|
* open. `thread` always speaks for the open chat, so a pane and a composer
|
|
73
85
|
* bound to it follow a switch.
|
|
74
86
|
*/
|
|
@@ -82,6 +94,10 @@ export interface ChatList {
|
|
|
82
94
|
remove(id: string): void;
|
|
83
95
|
setEngine(engine: ChatEngine | null): void;
|
|
84
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a list of chat threads, newest first, with one open; its `thread` always speaks for the
|
|
99
|
+
* open chat.
|
|
100
|
+
*/
|
|
85
101
|
export declare function chatList(o?: ThreadOptions): ChatList;
|
|
86
102
|
/** Tokens the next request carries, by source, for a context meter: about 4 characters a token (inferred). */
|
|
87
103
|
export declare function contextSegments(s: ThreadSnapshot, system?: string): {
|
package/dist/chat.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The state behind ChatPane and Composer
|
|
2
|
+
* The state behind ChatPane and Composer: a
|
|
3
3
|
* thread of turns, one live reply streamed from a @hackbuild/chat engine
|
|
4
4
|
* with its reasoning kept apart for the think fold, the memory each reply
|
|
5
5
|
* used, stop, regenerate, and a markdown export. Framework free.
|
|
6
6
|
*/
|
|
7
7
|
import { statsText } from "@virgilvox/hackbuild-ui/vanilla";
|
|
8
|
+
/** What a reply says when no chat engine is set. */
|
|
8
9
|
export const NO_ENGINE = "this needs a model. pick one in the bar and load it.";
|
|
10
|
+
/** Creates a chat thread that streams replies from an engine, with optional memory recall per message. */
|
|
9
11
|
export function chatThread(o = {}) {
|
|
10
12
|
let engine = o.engine ?? null;
|
|
11
13
|
const now = o.now ?? (() => Date.now());
|
|
@@ -128,6 +130,10 @@ export function chatThread(o = {}) {
|
|
|
128
130
|
},
|
|
129
131
|
};
|
|
130
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Creates a list of chat threads, newest first, with one open; its `thread` always speaks for the
|
|
135
|
+
* open chat.
|
|
136
|
+
*/
|
|
131
137
|
export function chatList(o = {}) {
|
|
132
138
|
const now = o.now ?? (() => Date.now());
|
|
133
139
|
let engine = o.engine ?? null;
|
package/dist/elements.d.ts
CHANGED
|
@@ -23,13 +23,19 @@ export { mountMemoryInspector, type MemoryInspector } from "./memory.js";
|
|
|
23
23
|
type Base = new () => HTMLElement;
|
|
24
24
|
/** The tag names define() registers, before any prefix. */
|
|
25
25
|
export declare const ELEMENT_NAMES: readonly ["model-select", "model-jobs", "chat-pane", "chat-composer", "chat-list", "chat-context", "transcribe-drop", "transcript-view", "transcribe-queue", "transcript-exports", "mask-studio", "mask-tools", "mask-verbs", "mask-rack", "frame-view", "camera-feed", "memory-inspector"];
|
|
26
|
+
/** A tag name `define` registers, before any prefix. */
|
|
26
27
|
export type ElementName = (typeof ELEMENT_NAMES)[number];
|
|
28
|
+
/**
|
|
29
|
+
* The `<model-select>` element: set `pick`, `env`, `loader` or `records` on it before or after it
|
|
30
|
+
* connects.
|
|
31
|
+
*/
|
|
27
32
|
export interface ModelSelectElement extends HTMLElement {
|
|
28
33
|
pick: ModelPick;
|
|
29
34
|
env: Env | undefined;
|
|
30
35
|
loader: Loader | undefined;
|
|
31
36
|
records: readonly ModelRecord[] | undefined;
|
|
32
37
|
}
|
|
38
|
+
/** The part of a custom element registry `define` uses; `customElements` satisfies it. */
|
|
33
39
|
export interface DefineTarget {
|
|
34
40
|
get(name: string): unknown;
|
|
35
41
|
define(name: string, ctor: CustomElementConstructor): void;
|
package/dist/frame.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface FrameBox {
|
|
|
13
13
|
/** 0 to 1. */
|
|
14
14
|
score?: number;
|
|
15
15
|
}
|
|
16
|
+
/** Landmark points to draw on a frame, with the index pairs to join and a label. */
|
|
16
17
|
export interface FrameLandmarks {
|
|
17
18
|
points: {
|
|
18
19
|
x: number;
|
|
@@ -22,6 +23,7 @@ export interface FrameLandmarks {
|
|
|
22
23
|
edges?: [number, number][];
|
|
23
24
|
label?: string;
|
|
24
25
|
}
|
|
26
|
+
/** What to draw on a frame: boxes, landmarks, a caption and a corner tag. */
|
|
25
27
|
export interface FrameResults {
|
|
26
28
|
boxes?: FrameBox[];
|
|
27
29
|
landmarks?: FrameLandmarks[];
|
package/dist/jobs.d.ts
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* than one place counts once, the running package's copy first.
|
|
6
6
|
*/
|
|
7
7
|
import { type ModelRecord } from "@hackbuild/models";
|
|
8
|
-
/** face-api weights (MIT)
|
|
8
|
+
/** Base URL of the face-api weights (MIT) on the package CDN. */
|
|
9
9
|
export declare const FACE_API_BASE = "https://cdn.jsdelivr.net/npm/@vladmandic/face-api@1.7.12/model/";
|
|
10
|
+
/** A job a model picker serves, such as chat, transcribe, vision or masks. */
|
|
10
11
|
export type Job = "chat" | "transcribe" | "vision" | "detect" | "masks" | "image" | "voice" | "depth" | "embed" | "faceswap" | "landmarks";
|
|
12
|
+
/** A job's words (line label, sheet title, empty line) and which capabilities serve it. */
|
|
11
13
|
export interface JobDef {
|
|
12
14
|
/** The word on a job line: "brain", "ears". */
|
|
13
15
|
label: string;
|
|
@@ -17,10 +19,13 @@ export interface JobDef {
|
|
|
17
19
|
empty: string;
|
|
18
20
|
provides: (caps: readonly string[]) => boolean;
|
|
19
21
|
}
|
|
22
|
+
/** The words and capability test of every job. */
|
|
20
23
|
export declare const JOBS: Readonly<Record<Job, JobDef>>;
|
|
24
|
+
/** Every job name, in the order of `JOBS`. */
|
|
21
25
|
export declare const JOB_NAMES: Job[];
|
|
22
26
|
/** Every record the views know, the running package's copy of a duplicate first. */
|
|
23
27
|
export declare const ALL_RECORDS: readonly ModelRecord[];
|
|
24
28
|
/** The records that do a job, catalogue order kept. */
|
|
25
29
|
export declare function jobRecords(job: Job, records?: readonly ModelRecord[]): ModelRecord[];
|
|
30
|
+
/** Whether a string is a job name. */
|
|
26
31
|
export declare function isJob(s: string | null | undefined): s is Job;
|
package/dist/jobs.js
CHANGED
|
@@ -10,9 +10,10 @@ import { IMAGEGEN_PICKER_RECORDS, IMAGEGEN_RECORDS } from "@hackbuild/imagegen";
|
|
|
10
10
|
import { SPEAK_RECORDS } from "@hackbuild/speak";
|
|
11
11
|
import { TRANSCRIBE_RECORDS } from "@hackbuild/transcribe";
|
|
12
12
|
import { PICKER_RECORDS, VISION_RECORDS, faceApiRecord } from "@hackbuild/vision";
|
|
13
|
-
/** face-api weights (MIT)
|
|
13
|
+
/** Base URL of the face-api weights (MIT) on the package CDN. */
|
|
14
14
|
export const FACE_API_BASE = "https://cdn.jsdelivr.net/npm/@vladmandic/face-api@1.7.12/model/";
|
|
15
15
|
const has = (...want) => (caps) => caps.some((c) => want.includes(c));
|
|
16
|
+
/** The words and capability test of every job. */
|
|
16
17
|
export const JOBS = {
|
|
17
18
|
chat: { label: "brain", title: "pick a chat model", empty: "no model", provides: has("chat") },
|
|
18
19
|
transcribe: { label: "ears", title: "pick a speech model", empty: "no speech model", provides: has("transcribe") },
|
|
@@ -26,6 +27,7 @@ export const JOBS = {
|
|
|
26
27
|
faceswap: { label: "face swap", title: "pick the face swap models", empty: "no face model", provides: has("face.detect", "face.embed", "face.swap") },
|
|
27
28
|
landmarks: { label: "landmarks", title: "pick a landmark model", empty: "no landmarks", provides: has("landmarks.face", "landmarks.hand", "landmarks.pose", "landmarks.gesture") },
|
|
28
29
|
};
|
|
30
|
+
/** Every job name, in the order of `JOBS`. */
|
|
29
31
|
export const JOB_NAMES = Object.keys(JOBS);
|
|
30
32
|
/** Every record the views know, the running package's copy of a duplicate first. */
|
|
31
33
|
export const ALL_RECORDS = (() => {
|
|
@@ -44,6 +46,7 @@ export function jobRecords(job, records = ALL_RECORDS) {
|
|
|
44
46
|
const def = JOBS[job];
|
|
45
47
|
return records.filter((r) => def.provides(r.provides));
|
|
46
48
|
}
|
|
49
|
+
/** Whether a string is a job name. */
|
|
47
50
|
export function isJob(s) {
|
|
48
51
|
return !!s && s in JOBS;
|
|
49
52
|
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Recall } from "@hackbuild/memory";
|
|
7
7
|
import { type Mounted } from "./dom.js";
|
|
8
|
+
/**
|
|
9
|
+
* One row of a recall trace as text: rank, id, kind, text, BM25, cosine, RRF, score, and whether it
|
|
10
|
+
* went to the model.
|
|
11
|
+
*/
|
|
8
12
|
export interface TraceRow {
|
|
9
13
|
rank: number;
|
|
10
14
|
id: number;
|
|
@@ -17,10 +21,15 @@ export interface TraceRow {
|
|
|
17
21
|
/** Inside the hits handed to the model. */
|
|
18
22
|
used: boolean;
|
|
19
23
|
}
|
|
24
|
+
/** The rows of a recall trace as text, marking the hits handed to the model. */
|
|
20
25
|
export declare function traceRows(r: Pick<Recall, "trace" | "hits">, maxText?: number): TraceRow[];
|
|
26
|
+
/** The parts of a memory recall the inspector shows: trace, hits, query and mode. */
|
|
21
27
|
export type RecallLike = Pick<Recall, "trace" | "hits" | "query" | "mode">;
|
|
28
|
+
/** The HTML of a recall trace table, or an empty note before any recall. */
|
|
22
29
|
export declare function inspectorHtml(rec: RecallLike | null): string;
|
|
30
|
+
/** A mounted memory inspector whose `set` shows a new recall. */
|
|
23
31
|
export interface MemoryInspector extends Mounted {
|
|
24
32
|
set(rec: RecallLike | null): void;
|
|
25
33
|
}
|
|
34
|
+
/** Shows a recall trace as a table on a host. */
|
|
26
35
|
export declare function mountMemoryInspector(host: HTMLElement, rec?: RecallLike | null): MemoryInspector;
|
package/dist/memory.js
CHANGED
|
@@ -7,6 +7,7 @@ import { esc } from "./dom.js";
|
|
|
7
7
|
const n3 = (x) => (Number.isFinite(x) ? x.toFixed(3) : "none");
|
|
8
8
|
// the core ranks from 0 (best) and uses -1 for absent; shown 1 based
|
|
9
9
|
const rank = (r) => (r >= 0 ? `#${r + 1}` : "none");
|
|
10
|
+
/** The rows of a recall trace as text, marking the hits handed to the model. */
|
|
10
11
|
export function traceRows(r, maxText = 80) {
|
|
11
12
|
const used = new Set(r.hits.map((h) => h.item.id));
|
|
12
13
|
return r.trace.map((t, i) => ({
|
|
@@ -21,6 +22,7 @@ export function traceRows(r, maxText = 80) {
|
|
|
21
22
|
used: used.has(t.id),
|
|
22
23
|
}));
|
|
23
24
|
}
|
|
25
|
+
/** The HTML of a recall trace table, or an empty note before any recall. */
|
|
24
26
|
export function inspectorHtml(rec) {
|
|
25
27
|
if (!rec)
|
|
26
28
|
return `<p class="hb-lay-empty-note">no recall yet. ask something to see what memory finds.</p>`;
|
|
@@ -30,6 +32,7 @@ export function inspectorHtml(rec) {
|
|
|
30
32
|
rows.map((x) => `<tr class="${x.used ? "is-mark" : ""}" data-used="${x.used}"><td class="num">${x.rank}</td><td>${esc(x.kind)}</td><td>${esc(x.text)}</td><td>${esc(x.bm25)}</td><td>${esc(x.cos)}</td><td class="num">${x.rrf}</td><td class="num">${x.score}</td></tr>`).join("") +
|
|
31
33
|
`</tbody></table></div>`);
|
|
32
34
|
}
|
|
35
|
+
/** Shows a recall trace as a table on a host. */
|
|
33
36
|
export function mountMemoryInspector(host, rec = null) {
|
|
34
37
|
host.innerHTML = inspectorHtml(rec);
|
|
35
38
|
return { set: (r) => void (host.innerHTML = inspectorHtml(r)), dispose() { } };
|
package/dist/mount-chat.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ChatPane and Composer in the DOM
|
|
2
|
+
* ChatPane and Composer in the DOM: the
|
|
3
3
|
* thread as hackbuild-ui messages, the reasoning in a fold that is open
|
|
4
4
|
* while it streams, the memory a reply used in a fold under it, copy and
|
|
5
5
|
* redo on the last reply only, and a composer whose send is the one pink
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type ChatList, type ChatThread, type Turn } from "./chat.js";
|
|
9
9
|
import { type Mounted } from "./dom.js";
|
|
10
|
+
/** Options for `mountChatPane`: the reply's name and the empty state's words. */
|
|
10
11
|
export interface ChatPaneOptions {
|
|
11
12
|
/** The reply's name in its head. */
|
|
12
13
|
name?: string;
|
|
@@ -14,6 +15,7 @@ export interface ChatPaneOptions {
|
|
|
14
15
|
emptyName?: string;
|
|
15
16
|
emptyNote?: string;
|
|
16
17
|
}
|
|
18
|
+
/** The HTML of one chat turn, with its reasoning fold, memory used and stats. */
|
|
17
19
|
export declare function turnHtml(t: Turn, o: {
|
|
18
20
|
name: string;
|
|
19
21
|
last: boolean;
|
|
@@ -21,6 +23,7 @@ export declare function turnHtml(t: Turn, o: {
|
|
|
21
23
|
}): string;
|
|
22
24
|
/** The thread over a host, with the empty state inside it. */
|
|
23
25
|
export declare function mountChatPane(host: HTMLElement, thread: ChatThread, o?: ChatPaneOptions): Mounted;
|
|
26
|
+
/** Options for `mountComposer`: placeholder and accessible label. */
|
|
24
27
|
export interface ComposerOptions {
|
|
25
28
|
placeholder?: string;
|
|
26
29
|
label?: string;
|