@hackbuild/ai-views 0.1.0 → 0.1.2
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 +248 -80
- package/dist/chat.d.ts +18 -2
- package/dist/chat.js +7 -1
- package/dist/elements.d.ts +7 -1
- package/dist/elements.js +1 -1
- package/dist/frame.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/jobs.d.ts +6 -1
- package/dist/jobs.js +4 -1
- package/dist/loaders.d.ts +100 -0
- package/dist/loaders.js +308 -0
- 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 +11 -1
- package/dist/mount-model.js +25 -4
- 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 +107 -53
- package/dist/single/elements.js +106 -54
- package/dist/single/index.iife.js +17042 -6168
- package/dist/single/index.js +17040 -6169
- package/dist/single/vue.iife.js +111 -48
- package/dist/single/vue.js +112 -48
- 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 +1233 -0
- package/package.json +14 -11
package/dist/single/elements.js
CHANGED
|
@@ -1415,6 +1415,7 @@ function Us(e, t) {
|
|
|
1415
1415
|
}
|
|
1416
1416
|
};
|
|
1417
1417
|
}
|
|
1418
|
+
/** Creates a chat thread that streams replies from an engine, with optional memory recall per message. */
|
|
1418
1419
|
function chatThread(o = {}) {
|
|
1419
1420
|
let engine = o.engine ?? null;
|
|
1420
1421
|
const now = o.now ?? (() => Date.now());
|
|
@@ -1567,6 +1568,10 @@ function chatThread(o = {}) {
|
|
|
1567
1568
|
}
|
|
1568
1569
|
};
|
|
1569
1570
|
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Creates a list of chat threads, newest first, with one open; its `thread` always speaks for the
|
|
1573
|
+
* open chat.
|
|
1574
|
+
*/
|
|
1570
1575
|
function chatList(o = {}) {
|
|
1571
1576
|
const now = o.now ?? (() => Date.now());
|
|
1572
1577
|
let engine = o.engine ?? null;
|
|
@@ -1726,7 +1731,7 @@ function ladderFor(rec, env) {
|
|
|
1726
1731
|
skipped
|
|
1727
1732
|
};
|
|
1728
1733
|
}
|
|
1729
|
-
/** The onnxruntime-web ladder
|
|
1734
|
+
/** The onnxruntime-web ladder to walk after one fetch: webgpu at basic, all, disabled, then wasm. */
|
|
1730
1735
|
function ortLadder() {
|
|
1731
1736
|
return [
|
|
1732
1737
|
{
|
|
@@ -1760,6 +1765,7 @@ function ortLadder() {
|
|
|
1760
1765
|
];
|
|
1761
1766
|
}
|
|
1762
1767
|
// packages/models/src/pins.ts
|
|
1768
|
+
/** Pinned commits and file hashes per Hugging Face repo, written by tools/pin-weights.mjs. */
|
|
1763
1769
|
const PINS = {
|
|
1764
1770
|
"HuggingFaceTB/SmolLM2-135M-Instruct": {
|
|
1765
1771
|
"revision": "12fd25f77366fa6b3b4b768ec3050bf629380bac",
|
|
@@ -4608,6 +4614,7 @@ const PINS = {
|
|
|
4608
4614
|
* added to a registry, so every loader resolves `resolve/<commit>/` URLs,
|
|
4609
4615
|
* and pinnedSha gives the SHA-256 for such a URL.
|
|
4610
4616
|
*/
|
|
4617
|
+
/** The pin of a repo, or undefined when the repo is not pinned. */
|
|
4611
4618
|
function pinOf(repo) {
|
|
4612
4619
|
return repo && Object.hasOwn(PINS, repo) ? PINS[repo] : void 0;
|
|
4613
4620
|
}
|
|
@@ -4617,15 +4624,15 @@ function pinnedBase(repo, fallback = "main") {
|
|
|
4617
4624
|
}
|
|
4618
4625
|
// packages/models/src/catalog.ts
|
|
4619
4626
|
/**
|
|
4620
|
-
* Starter records. Sizes marked "inferred" come from
|
|
4627
|
+
* Starter records. Sizes marked "inferred" come from published tables or
|
|
4621
4628
|
* from parameter count times bits and are not measured downloads. Chat rows
|
|
4622
4629
|
* marked "measured" sum the Content-Length of a HEAD request on every file
|
|
4623
4630
|
* the runtime loads, at the repo head of 2026-11-24, in MiB; no weight was
|
|
4624
4631
|
* downloaded. WebLLM rows count the Hugging Face repo and leave out the
|
|
4625
4632
|
* model library wasm, which comes from another host. Licences on the older rows are the ones on each model card as
|
|
4626
4633
|
* of 2026-11-22; on the chat rows added 2026-11-24 they are the model card
|
|
4627
|
-
* licence field the Hugging Face API returns, or
|
|
4628
|
-
*
|
|
4634
|
+
* licence field the Hugging Face API returns, or a recorded string, and
|
|
4635
|
+
* were not checked (owner decision). Recheck before shipping a
|
|
4629
4636
|
* product on them. Add your own records with registry.add().
|
|
4630
4637
|
*
|
|
4631
4638
|
* vramMB marked "computed" on the 14 WebLLM rows added 2026-11-25 is the
|
|
@@ -4634,13 +4641,13 @@ function pinnedBase(repo, fallback = "main") {
|
|
|
4634
4641
|
* Rows with sizeSource "vendor" added 2026-11-25 sum the file sizes of the
|
|
4635
4642
|
* Hugging Face listing of the repo (no download), converted to MiB.
|
|
4636
4643
|
* Every row carries a speed word and a verdict of one to four words: what
|
|
4637
|
-
* a person picks by, in the owner's voice
|
|
4644
|
+
* a person picks by, in the owner's voice.
|
|
4638
4645
|
*
|
|
4639
4646
|
* Catalogue facts (params, quant, VRAM, censorship, tags, note) are copied
|
|
4640
|
-
* from the
|
|
4641
|
-
* design harvest; VRAM figures are the catalogue's own (vendor). Licence
|
|
4647
|
+
* from the owner's model labels and the WebLLM catalogue; VRAM figures are the catalogue's own (vendor). Licence
|
|
4642
4648
|
* strings are shown as recorded and were not verified for these facts.
|
|
4643
4649
|
*/
|
|
4650
|
+
/** The starter model records, each with its size source and weight licence. */
|
|
4644
4651
|
const CATALOG = [
|
|
4645
4652
|
{
|
|
4646
4653
|
id: "smollm2-135m-instruct",
|
|
@@ -5196,7 +5203,7 @@ const CATALOG = [
|
|
|
5196
5203
|
tier: "large",
|
|
5197
5204
|
family: "gemma",
|
|
5198
5205
|
tags: [],
|
|
5199
|
-
note: "an uncensored gemma 4 brain.
|
|
5206
|
+
note: "an uncensored gemma 4 brain. it warns with no webgpu.",
|
|
5200
5207
|
group: "uncensored",
|
|
5201
5208
|
badge: "best",
|
|
5202
5209
|
speed: "slow",
|
|
@@ -5230,7 +5237,7 @@ const CATALOG = [
|
|
|
5230
5237
|
tier: "medium",
|
|
5231
5238
|
family: "gemma",
|
|
5232
5239
|
tags: [],
|
|
5233
|
-
note: "lighter gemma 4.
|
|
5240
|
+
note: "lighter gemma 4. a chat default with webgpu.",
|
|
5234
5241
|
group: "uncensored",
|
|
5235
5242
|
badge: "lighter",
|
|
5236
5243
|
speed: "steady",
|
|
@@ -5406,7 +5413,7 @@ const CATALOG = [
|
|
|
5406
5413
|
tier: "small",
|
|
5407
5414
|
family: "qwen3.5",
|
|
5408
5415
|
tags: ["no gpu"],
|
|
5409
|
-
note: "
|
|
5416
|
+
note: "a chat default with no webgpu. thin for long chats.",
|
|
5410
5417
|
group: "uncensored",
|
|
5411
5418
|
badge: "faster",
|
|
5412
5419
|
speed: "fast",
|
|
@@ -5538,7 +5545,7 @@ const CATALOG = [
|
|
|
5538
5545
|
tier: "small",
|
|
5539
5546
|
family: "qwen3",
|
|
5540
5547
|
tags: ["think"],
|
|
5541
|
-
note: "a small qwen3 with a think trace.
|
|
5548
|
+
note: "a small qwen3 with a think trace. fits a deliberator role.",
|
|
5542
5549
|
group: "reasoning",
|
|
5543
5550
|
badge: "think, easier on memory",
|
|
5544
5551
|
speed: "fast",
|
|
@@ -6208,25 +6215,25 @@ function tjsLadder(spec) {
|
|
|
6208
6215
|
}
|
|
6209
6216
|
return spec.wasmFirst ? [...cpu, ...gpu] : [...gpu, ...cpu];
|
|
6210
6217
|
}
|
|
6211
|
-
/** onnxruntime-web rungs:
|
|
6218
|
+
/** onnxruntime-web rungs: webgpu then wasm, or wasm only when the graph is known to fail on webgpu. */
|
|
6212
6219
|
function ortRungs(opts = {}) {
|
|
6213
6220
|
const all = ortLadder();
|
|
6214
6221
|
return opts.webgpu === false ? all.filter((r) => r.device === "wasm") : all;
|
|
6215
6222
|
}
|
|
6216
|
-
/** Ladders by name,
|
|
6223
|
+
/** Ladders by name, one per model family. Each model record may copy one or write its own. */
|
|
6217
6224
|
const LADDERS = {
|
|
6218
|
-
/**
|
|
6225
|
+
/** Depth: fp16 then fp32 on webgpu, q8 then fp32 on wasm. */
|
|
6219
6226
|
depth: () => tjsLadder({
|
|
6220
6227
|
webgpu: ["fp16", "fp32"],
|
|
6221
6228
|
wasm: ["q8", "fp32"]
|
|
6222
6229
|
}),
|
|
6223
|
-
/**
|
|
6230
|
+
/** Perception models on cpu by default. */
|
|
6224
6231
|
perceptionCpu: () => tjsLadder({
|
|
6225
6232
|
webgpu: ["fp32"],
|
|
6226
6233
|
wasm: ["q8", "fp32"],
|
|
6227
6234
|
wasmFirst: true
|
|
6228
6235
|
}),
|
|
6229
|
-
/** whisper-large-v3-turbo (weights MIT)
|
|
6236
|
+
/** whisper-large-v3-turbo (weights MIT). */
|
|
6230
6237
|
whisperTurbo: () => tjsLadder({
|
|
6231
6238
|
webgpu: [{
|
|
6232
6239
|
encoder_model: "fp16",
|
|
@@ -6251,7 +6258,7 @@ const LADDERS = {
|
|
|
6251
6258
|
decoder_model_merged: "q8"
|
|
6252
6259
|
}]
|
|
6253
6260
|
}),
|
|
6254
|
-
/** SmolVLM (weights Apache-2.0): fp16 embed and vision, q4 decoder on webgpu; q8 vision on wasm
|
|
6261
|
+
/** SmolVLM (weights Apache-2.0): fp16 embed and vision, q4 decoder on webgpu; q8 vision on wasm. */
|
|
6255
6262
|
smolvlm: () => tjsLadder({
|
|
6256
6263
|
webgpu: [{
|
|
6257
6264
|
embed_tokens: "fp32",
|
|
@@ -6269,7 +6276,7 @@ const LADDERS = {
|
|
|
6269
6276
|
}],
|
|
6270
6277
|
freshHeapRetry: true
|
|
6271
6278
|
}),
|
|
6272
|
-
/**
|
|
6279
|
+
/** q4f16 on webgpu only. */
|
|
6273
6280
|
vlmGpuOnly: () => tjsLadder({ webgpu: ["q4f16", "q4"] }),
|
|
6274
6281
|
ort: ortRungs
|
|
6275
6282
|
};
|
|
@@ -6278,6 +6285,7 @@ const LADDERS = {
|
|
|
6278
6285
|
* Embedder records for the models hub. Sizes are inferred from the model
|
|
6279
6286
|
* repos' file lists; licences are the model cards' as of 2026-11-22.
|
|
6280
6287
|
*/
|
|
6288
|
+
/** Hub records for potion-base-8M, all-MiniLM-L6-v2 and bge-small-en-v1.5. */
|
|
6281
6289
|
const EMBED_RECORDS = [
|
|
6282
6290
|
{
|
|
6283
6291
|
id: "potion-base-8m",
|
|
@@ -6297,7 +6305,7 @@ const EMBED_RECORDS = [
|
|
|
6297
6305
|
licence: "MIT",
|
|
6298
6306
|
commercial: true,
|
|
6299
6307
|
place: "main",
|
|
6300
|
-
notes: ["256 dims, no runtime, about 0.08 ms per sentence
|
|
6308
|
+
notes: ["256 dims, no runtime, about 0.08 ms per sentence (measured outside this repository)", "misses paraphrase"]
|
|
6301
6309
|
},
|
|
6302
6310
|
{
|
|
6303
6311
|
id: "minilm-l6",
|
|
@@ -6319,7 +6327,7 @@ const EMBED_RECORDS = [
|
|
|
6319
6327
|
commercial: true,
|
|
6320
6328
|
place: "cpu-worker",
|
|
6321
6329
|
runtime: "@huggingface/transformers@4.3.2",
|
|
6322
|
-
notes: ["384 dims; webgpu with q8 garbled other models
|
|
6330
|
+
notes: ["384 dims; webgpu with q8 garbled other models, so q8 stays on wasm"]
|
|
6323
6331
|
},
|
|
6324
6332
|
{
|
|
6325
6333
|
id: "bge-small-en",
|
|
@@ -6365,6 +6373,7 @@ const free512 = { freeDimensionOverrides: {
|
|
|
6365
6373
|
height_latent: 64,
|
|
6366
6374
|
width_latent: 64
|
|
6367
6375
|
} };
|
|
6376
|
+
/** The image models {@link attachImagegen} registers: SD-Turbo and SD 1.5, each with its licence, size and form. */
|
|
6368
6377
|
const IMAGEGEN_RECORDS = [{
|
|
6369
6378
|
id: "sd-turbo",
|
|
6370
6379
|
label: "sd-turbo 512",
|
|
@@ -6389,9 +6398,9 @@ const IMAGEGEN_RECORDS = [{
|
|
|
6389
6398
|
place: "gpu",
|
|
6390
6399
|
runtime: "onnxruntime-web@1.27.0",
|
|
6391
6400
|
notes: [
|
|
6392
|
-
"webgpu only
|
|
6401
|
+
"webgpu only, no wasm floor",
|
|
6393
6402
|
"tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)",
|
|
6394
|
-
"graph file paths inferred
|
|
6403
|
+
"graph file paths inferred, not checked against the repo"
|
|
6395
6404
|
],
|
|
6396
6405
|
form: {
|
|
6397
6406
|
steps: {
|
|
@@ -6431,7 +6440,7 @@ const IMAGEGEN_RECORDS = [{
|
|
|
6431
6440
|
place: "gpu",
|
|
6432
6441
|
runtime: "onnxruntime-web@1.27.0",
|
|
6433
6442
|
notes: [
|
|
6434
|
-
"about 2 GB
|
|
6443
|
+
"about 2 GB (vendor); the repo, its file paths and its input dtypes are inferred and not checked",
|
|
6435
6444
|
"runs the unet twice a step for guidance, so a step costs about twice an sd-turbo step (inferred)",
|
|
6436
6445
|
"tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)"
|
|
6437
6446
|
],
|
|
@@ -6488,7 +6497,7 @@ const IMAGEGEN_PICKER_RECORDS = [{
|
|
|
6488
6497
|
commercial: "unknown",
|
|
6489
6498
|
place: "gpu",
|
|
6490
6499
|
runtime: "onnxruntime-web@1.27.0",
|
|
6491
|
-
notes: ["two text encoders; the pipeline in this package runs one, so this record is listed and not run yet", "
|
|
6500
|
+
notes: ["two text encoders; the pipeline in this package runs one, so this record is listed and not run yet", "the highest quality of the three image models"],
|
|
6492
6501
|
form: {
|
|
6493
6502
|
steps: {
|
|
6494
6503
|
min: 1,
|
|
@@ -6532,6 +6541,7 @@ function toTxt(segs) {
|
|
|
6532
6541
|
function cueText(t) {
|
|
6533
6542
|
return t.replace(/-->/g, "->").replace(/\n\s*\n/g, "\n");
|
|
6534
6543
|
}
|
|
6544
|
+
/** SubRip text: numbered cues with comma millisecond stamps. */
|
|
6535
6545
|
function toSrt(segs) {
|
|
6536
6546
|
return segs.map((s, i) => `${i + 1}\n${timestamp(s.start, true)} --> ${timestamp(s.end, true)}\n${cueText(s.text)}\n`).join("\n");
|
|
6537
6547
|
}
|
|
@@ -6545,6 +6555,7 @@ function toSrt(segs) {
|
|
|
6545
6555
|
return t;
|
|
6546
6556
|
})();
|
|
6547
6557
|
// packages/speak/src/records.ts
|
|
6558
|
+
/** Model records for the voices this package drives, for pickers and the models registry. */
|
|
6548
6559
|
const SPEAK_RECORDS = [
|
|
6549
6560
|
{
|
|
6550
6561
|
id: "kokoro-82m",
|
|
@@ -6569,7 +6580,7 @@ const SPEAK_RECORDS = [
|
|
|
6569
6580
|
commercial: true,
|
|
6570
6581
|
place: "cpu-worker",
|
|
6571
6582
|
runtime: "kokoro-js@1.2.1",
|
|
6572
|
-
notes: ["webgpu with q8
|
|
6583
|
+
notes: ["webgpu with q8 has given garbled audio", "fp32 weights (about 330 MB, inferred) do not cache on file://, so webgpu needs http"]
|
|
6573
6584
|
},
|
|
6574
6585
|
{
|
|
6575
6586
|
id: "pocket-tts",
|
|
@@ -6637,8 +6648,7 @@ const SPEAK_RECORDS = [
|
|
|
6637
6648
|
// packages/transcribe/src/records.ts
|
|
6638
6649
|
/**
|
|
6639
6650
|
* Speech to text records for the models hub. Ladders and dtypes are
|
|
6640
|
-
*
|
|
6641
|
-
* notes, except rows marked vendor: those sum the quantized encoder and
|
|
6651
|
+
* one per model table; sizes are inferred from the model notes, except rows marked vendor: those sum the quantized encoder and
|
|
6642
6652
|
* decoder in the hub listing (no download, 2026-11-25), in MiB. Licences are the model cards' as of 2026-11-22.
|
|
6643
6653
|
*/
|
|
6644
6654
|
const asr = (r) => ({
|
|
@@ -6650,6 +6660,7 @@ const asr = (r) => ({
|
|
|
6650
6660
|
runtime: "@huggingface/transformers@4.3.2",
|
|
6651
6661
|
...r
|
|
6652
6662
|
});
|
|
6663
|
+
/** The Whisper and Moonshine model records for the models hub. */
|
|
6653
6664
|
const TRANSCRIBE_RECORDS = [
|
|
6654
6665
|
asr({
|
|
6655
6666
|
id: "whisper-large-v3-turbo",
|
|
@@ -6663,7 +6674,7 @@ const TRANSCRIBE_RECORDS = [
|
|
|
6663
6674
|
ladder: LADDERS.whisperTurbo(),
|
|
6664
6675
|
licence: "MIT",
|
|
6665
6676
|
place: "gpu",
|
|
6666
|
-
notes: ["best accuracy, multilingual, wants webgpu
|
|
6677
|
+
notes: ["best accuracy, multilingual, wants webgpu", "download per rung: 1.5 gb fp16 encoder and q4 decoder, 2.7 gb fp32 encoder, 1.0 gb q8 on wasm (vendor)"]
|
|
6667
6678
|
}),
|
|
6668
6679
|
asr({
|
|
6669
6680
|
id: "whisper-base",
|
|
@@ -6700,7 +6711,7 @@ const TRANSCRIBE_RECORDS = [
|
|
|
6700
6711
|
sizeMB: 90,
|
|
6701
6712
|
ladder: LADDERS.whisperSmall(false),
|
|
6702
6713
|
licence: "MIT (the OpenAI Whisper release; the Xenova ONNX card says apache-2.0)",
|
|
6703
|
-
notes: ["english only; the
|
|
6714
|
+
notes: ["english only; the default with no gpu"]
|
|
6704
6715
|
}),
|
|
6705
6716
|
asr({
|
|
6706
6717
|
id: "whisper-tiny.en",
|
|
@@ -6741,15 +6752,15 @@ const TRANSCRIBE_RECORDS = [
|
|
|
6741
6752
|
];
|
|
6742
6753
|
// packages/transcribe/src/export.ts
|
|
6743
6754
|
/**
|
|
6744
|
-
* Transcript exports
|
|
6755
|
+
* Transcript exports as txt, srt,
|
|
6745
6756
|
* vtt and json per file, and one store only zip with four files per
|
|
6746
6757
|
* source plus `manifest.json`. The manifest records the model and language
|
|
6747
|
-
* of each file's own run
|
|
6748
|
-
* export time, which could differ from the run). A speaker label, when a
|
|
6758
|
+
* of each file's own run. A speaker label, when a
|
|
6749
6759
|
* person set one, leads the line in txt and srt and is a voice tag in vtt.
|
|
6750
6760
|
*/
|
|
6751
6761
|
const said = (s) => s.speaker ? `${s.speaker}: ${s.text}` : s.text;
|
|
6752
6762
|
const r3 = (x) => +x.toFixed(3);
|
|
6763
|
+
/** Plain text with speaker labels leading their lines; a gap over 2 s starts a paragraph. */
|
|
6753
6764
|
function asTxt(segs) {
|
|
6754
6765
|
return toTxt(segs.map((s) => ({
|
|
6755
6766
|
start: s.start,
|
|
@@ -6757,6 +6768,7 @@ function asTxt(segs) {
|
|
|
6757
6768
|
text: said(s)
|
|
6758
6769
|
})));
|
|
6759
6770
|
}
|
|
6771
|
+
/** SubRip text with speaker labels leading their lines. */
|
|
6760
6772
|
function asSrt(segs) {
|
|
6761
6773
|
return toSrt(segs.map((s) => ({
|
|
6762
6774
|
start: s.start,
|
|
@@ -6765,6 +6777,7 @@ function asSrt(segs) {
|
|
|
6765
6777
|
})));
|
|
6766
6778
|
}
|
|
6767
6779
|
const esc$1 = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
6780
|
+
/** WebVTT text with speakers as voice tags and cue text escaped. */
|
|
6768
6781
|
function asVtt(segs) {
|
|
6769
6782
|
const cue = (s) => {
|
|
6770
6783
|
const body = esc$1(s.text.replace(/-->/g, "->").replace(/\n\s*\n/g, "\n"));
|
|
@@ -6820,6 +6833,7 @@ function baseName(name) {
|
|
|
6820
6833
|
* only for a URL the app supplies; YOLOv10 n, s and m, FastSAM and the face
|
|
6821
6834
|
* swap set sit in PICKER_RECORDS.
|
|
6822
6835
|
*/
|
|
6836
|
+
/** The MediaPipe model storage base URL the MediaPipe records load from. */
|
|
6823
6837
|
const MP_MODELS = "https://storage.googleapis.com/mediapipe-models/";
|
|
6824
6838
|
/** MediaPipe ladder: GPU delegate (webgl), then the CPU delegate (wasm). */
|
|
6825
6839
|
const mediapipeLadder = () => [{ device: "webgl" }, { device: "wasm" }];
|
|
@@ -6840,6 +6854,7 @@ const mp = (id, provides, path, sizeMB, label, verdict = "light, on the gpu", gr
|
|
|
6840
6854
|
place: "main",
|
|
6841
6855
|
runtime: "@mediapipe/tasks-vision@1.2.3"
|
|
6842
6856
|
});
|
|
6857
|
+
/** The vision records registered by `attachVision`: Depth Anything V2 small, MediaPipe detection, segmentation and landmarks, SlimSAM, SmolVLM 256M and LFM2-VL 450M. */
|
|
6843
6858
|
const VISION_RECORDS = [
|
|
6844
6859
|
{
|
|
6845
6860
|
id: "depth-anything-v2-small",
|
|
@@ -6857,7 +6872,7 @@ const VISION_RECORDS = [
|
|
|
6857
6872
|
commercial: true,
|
|
6858
6873
|
place: "cpu-worker",
|
|
6859
6874
|
runtime: "@huggingface/transformers@4.3.2",
|
|
6860
|
-
notes: ["
|
|
6875
|
+
notes: ["fp16 on webgpu, fp32 on the same device after a failure"]
|
|
6861
6876
|
},
|
|
6862
6877
|
mp("efficientdet-lite0", "detect", "object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite", 7, "mediapipe efficientdet lite0 (coco, 80 classes)", "light, 80 things"),
|
|
6863
6878
|
mp("selfie-segmenter", "segment.person", "image_segmenter/selfie_segmenter/float16/latest/selfie_segmenter.tflite", 1, "mediapipe selfie segmenter"),
|
|
@@ -6889,7 +6904,7 @@ const VISION_RECORDS = [
|
|
|
6889
6904
|
commercial: true,
|
|
6890
6905
|
place: "cpu-worker",
|
|
6891
6906
|
runtime: "@huggingface/transformers@4.3.2",
|
|
6892
|
-
notes: ["
|
|
6907
|
+
notes: ["one image embedding, then any number of point prompts"]
|
|
6893
6908
|
},
|
|
6894
6909
|
{
|
|
6895
6910
|
id: "smolvlm-256m-instruct",
|
|
@@ -6932,13 +6947,12 @@ const VISION_RECORDS = [
|
|
|
6932
6947
|
commercial: "unknown",
|
|
6933
6948
|
place: "gpu",
|
|
6934
6949
|
runtime: "@huggingface/transformers@4.3.2",
|
|
6935
|
-
notes: ["
|
|
6950
|
+
notes: ["q4f16 on webgpu only; the licence limits commercial use by revenue, read it before shipping"]
|
|
6936
6951
|
}
|
|
6937
6952
|
];
|
|
6938
6953
|
/**
|
|
6939
6954
|
* Records listed for pickers and never registered by default, so a hub's
|
|
6940
|
-
* routing by capability keeps its small defaults: larger alternates
|
|
6941
|
-
* earlier tools offered (smolvlm 500m and 2 video, gemma 4 e2b, two more
|
|
6955
|
+
* routing by capability keeps its small defaults: larger alternates (smolvlm 500m and 2 video, gemma 4 e2b, two more
|
|
6942
6956
|
* depth models), and records under licences that limit use (YOLOv10 and
|
|
6943
6957
|
* FastSAM are AGPL-3.0 upstream, Ultralytics; the face swap set is
|
|
6944
6958
|
* InsightFace, non-commercial). A hub that runs one adds it itself. Sizes
|
|
@@ -6972,8 +6986,9 @@ const yolo10 = (size, mb, speed, verdict) => ({
|
|
|
6972
6986
|
licence: "AGPL-3.0 (Ultralytics weights, the model card's licence field)",
|
|
6973
6987
|
commercial: false,
|
|
6974
6988
|
place: "gpu",
|
|
6975
|
-
notes: ["output [1, 300, 6] after the model's own selection, so no nms pass (vendor, the yolov10 paper)", "
|
|
6989
|
+
notes: ["output [1, 300, 6] after the model's own selection, so no nms pass (vendor, the yolov10 paper)", "comes in nano, small and medium"]
|
|
6976
6990
|
});
|
|
6991
|
+
/** Records listed for pickers and never registered by default: larger alternates, and records under licences that limit use (YOLOv10, FastSAM, the face swap set). */
|
|
6977
6992
|
const PICKER_RECORDS = [
|
|
6978
6993
|
{
|
|
6979
6994
|
id: "smolvlm-500m-instruct",
|
|
@@ -7016,7 +7031,7 @@ const PICKER_RECORDS = [
|
|
|
7016
7031
|
commercial: true,
|
|
7017
7032
|
place: "cpu-worker",
|
|
7018
7033
|
runtime: "@huggingface/transformers@4.3.2",
|
|
7019
|
-
notes: ["an
|
|
7034
|
+
notes: ["an option beside smolvlm 256m and 500m"]
|
|
7020
7035
|
},
|
|
7021
7036
|
{
|
|
7022
7037
|
id: "depth-anything-v2-base",
|
|
@@ -7073,7 +7088,7 @@ const PICKER_RECORDS = [
|
|
|
7073
7088
|
commercial: true,
|
|
7074
7089
|
place: "gpu",
|
|
7075
7090
|
runtime: "@huggingface/transformers@4.3.2",
|
|
7076
|
-
notes: ["
|
|
7091
|
+
notes: ["about 3.3 GB (vendor)"]
|
|
7077
7092
|
},
|
|
7078
7093
|
yolo10("n", 9, "instant", "nano, quick"),
|
|
7079
7094
|
yolo10("s", 28, "fast", "small, sharper"),
|
|
@@ -7102,7 +7117,7 @@ const PICKER_RECORDS = [
|
|
|
7102
7117
|
licence: "AGPL-3.0 upstream (Ultralytics FastSAM); the export's card says apache-2.0",
|
|
7103
7118
|
commercial: false,
|
|
7104
7119
|
place: "cpu-worker",
|
|
7105
|
-
notes: ["
|
|
7120
|
+
notes: ["finds every mask in one pass on onnxruntime-web (93 MB, vendor)", "segment everything: prototype masks, nms, then a pick by click"]
|
|
7106
7121
|
},
|
|
7107
7122
|
{
|
|
7108
7123
|
id: "scrfd-10g",
|
|
@@ -7175,7 +7190,7 @@ const PICKER_RECORDS = [
|
|
|
7175
7190
|
licence: "InsightFace: non-commercial research only; the mirror's card says gpl-3.0",
|
|
7176
7191
|
commercial: false,
|
|
7177
7192
|
place: "gpu",
|
|
7178
|
-
notes: ["128 px faces;
|
|
7193
|
+
notes: ["128 px faces; paste the result back with a feathered mask"]
|
|
7179
7194
|
}
|
|
7180
7195
|
];
|
|
7181
7196
|
/** A face landmark fallback record over face-api.js tiny nets (code MIT; weights MIT from @vladmandic/face-api). */
|
|
@@ -7204,9 +7219,10 @@ function faceApiRecord(baseUrl) {
|
|
|
7204
7219
|
* records come from the packages that run them; a record listed in more
|
|
7205
7220
|
* than one place counts once, the running package's copy first.
|
|
7206
7221
|
*/
|
|
7207
|
-
/** face-api weights (MIT)
|
|
7222
|
+
/** Base URL of the face-api weights (MIT) on the package CDN. */
|
|
7208
7223
|
const FACE_API_BASE = "https://cdn.jsdelivr.net/npm/@vladmandic/face-api@1.7.12/model/";
|
|
7209
7224
|
const has = (...want) => (caps) => caps.some((c) => want.includes(c));
|
|
7225
|
+
/** The words and capability test of every job. */
|
|
7210
7226
|
const JOBS = {
|
|
7211
7227
|
chat: {
|
|
7212
7228
|
label: "brain",
|
|
@@ -7302,6 +7318,7 @@ function jobRecords(job, records = ALL_RECORDS) {
|
|
|
7302
7318
|
const def = JOBS[job];
|
|
7303
7319
|
return records.filter((r) => def.provides(r.provides));
|
|
7304
7320
|
}
|
|
7321
|
+
/** Whether a string is a job name. */
|
|
7305
7322
|
function isJob(s) {
|
|
7306
7323
|
return !!s && s in JOBS;
|
|
7307
7324
|
}
|
|
@@ -7318,9 +7335,11 @@ const GROUPS = {
|
|
|
7318
7335
|
"no download": "none",
|
|
7319
7336
|
own: "own"
|
|
7320
7337
|
};
|
|
7338
|
+
/** Whether a record has nothing to download: a built in, system or zero size model. */
|
|
7321
7339
|
function isNoDownload(r) {
|
|
7322
7340
|
return !!r.noDownload || r.sizeMB === 0 || r.provider === "prompt-api" || r.provider === "system";
|
|
7323
7341
|
}
|
|
7342
|
+
/** Whether a record's censorship is "uncensored" or "abliterated". */
|
|
7324
7343
|
function isUncensored(r) {
|
|
7325
7344
|
return r.censorship === "uncensored" || r.censorship === "abliterated";
|
|
7326
7345
|
}
|
|
@@ -7553,6 +7572,7 @@ function defaultPick(records, env, estimate) {
|
|
|
7553
7572
|
}).unfit === void 0);
|
|
7554
7573
|
return (fits.find((r) => r.group === "start here") ?? fits.find((r) => r.speed === "fast" || r.speed === "steady") ?? fits[0] ?? records[0])?.id ?? "";
|
|
7555
7574
|
}
|
|
7575
|
+
/** Creates a model picker for a job, with rows that say whether each model fits this machine. */
|
|
7556
7576
|
function useModelPick(job, o = {}) {
|
|
7557
7577
|
const def = JOBS[job];
|
|
7558
7578
|
let records = jobRecords(job, o.records ?? ALL_RECORDS);
|
|
@@ -7692,6 +7712,7 @@ function useModelPick(job, o = {}) {
|
|
|
7692
7712
|
error: (id) => errors.get(id)
|
|
7693
7713
|
};
|
|
7694
7714
|
}
|
|
7715
|
+
/** Creates one picker per job and joins them as a rack with presets and load all. */
|
|
7695
7716
|
function useJobsPick(jobs, initialPresets = [], shared = {}) {
|
|
7696
7717
|
let presets = initialPresets;
|
|
7697
7718
|
const extra = /* @__PURE__ */ new Set();
|
|
@@ -7818,13 +7839,14 @@ const ICON = {
|
|
|
7818
7839
|
};
|
|
7819
7840
|
// packages/ai-views/src/mount-chat.ts
|
|
7820
7841
|
/**
|
|
7821
|
-
* ChatPane and Composer in the DOM
|
|
7842
|
+
* ChatPane and Composer in the DOM: the
|
|
7822
7843
|
* thread as hackbuild-ui messages, the reasoning in a fold that is open
|
|
7823
7844
|
* while it streams, the memory a reply used in a fold under it, copy and
|
|
7824
7845
|
* redo on the last reply only, and a composer whose send is the one pink
|
|
7825
7846
|
* action and turns into stop while a reply streams.
|
|
7826
7847
|
*/
|
|
7827
7848
|
const paras = (t) => t.split(/\n{2,}/).map((p) => p.trim()).filter(Boolean).map((p) => `<div class="hb-msg-text">${esc(p).replace(/\n/g, "<br>")}</div>`).join("");
|
|
7849
|
+
/** The HTML of one chat turn, with its reasoning fold, memory used and stats. */
|
|
7828
7850
|
function turnHtml(t, o) {
|
|
7829
7851
|
if (t.role === "user") return `<div class="hb-msg is-user" data-turn="${t.id}"><span class="hb-msg-who"><span class="hb-msg-name">you</span></span><div class="hb-msg-parts">${paras(t.text)}</div></div>`;
|
|
7830
7852
|
const live = !t.done;
|
|
@@ -8009,7 +8031,7 @@ function labelColour(label, palette) {
|
|
|
8009
8031
|
}
|
|
8010
8032
|
// packages/ai-views/src/mount-frame.ts
|
|
8011
8033
|
/**
|
|
8012
|
-
* FrameView and CameraFeed
|
|
8034
|
+
* FrameView and CameraFeed: a
|
|
8013
8035
|
* frame in a hackbuild-ui camera tile with what the models found drawn
|
|
8014
8036
|
* over it (boxes with their word and score, landmark points and lines),
|
|
8015
8037
|
* a count in the corner and the caption under it. CameraFeed opens the
|
|
@@ -8022,6 +8044,7 @@ const css = (el, name, fb) => {
|
|
|
8022
8044
|
return fb;
|
|
8023
8045
|
}
|
|
8024
8046
|
};
|
|
8047
|
+
/** Draws a frame in a camera tile on a host, with boxes, landmarks, a corner tag and a caption over it. */
|
|
8025
8048
|
function mountFrameView(host, o = {}) {
|
|
8026
8049
|
host.innerHTML = `<div class="hb-frameview"><figure class="hb-camtile" aria-label="frame"><div class="hb-camtile-none" role="status">${esc(o.empty ?? "no frame yet")}</div><canvas aria-hidden="true"></canvas><span class="hb-camtile-tag is-tl" hidden></span></figure><p class="hb-frameview-cap" data-caption aria-live="polite" hidden></p></div>`;
|
|
8027
8050
|
const fig = host.querySelector("figure");
|
|
@@ -8177,6 +8200,7 @@ function mountFrameView(host, o = {}) {
|
|
|
8177
8200
|
dispose: () => l.off()
|
|
8178
8201
|
};
|
|
8179
8202
|
}
|
|
8203
|
+
/** Opens the camera into a host and hands the video to `onFrame` at the set rate while it is live. */
|
|
8180
8204
|
function mountCameraFeed(host, o = {}) {
|
|
8181
8205
|
const video = document.createElement("video");
|
|
8182
8206
|
video.autoplay = true;
|
|
@@ -8257,7 +8281,7 @@ function mountCameraFeed(host, o = {}) {
|
|
|
8257
8281
|
}
|
|
8258
8282
|
// packages/ai-views/src/mount-mask.ts
|
|
8259
8283
|
/**
|
|
8260
|
-
* MaskStudio
|
|
8284
|
+
* MaskStudio: drop an image, press a thing
|
|
8261
8285
|
* to cut it out (a click segment model such as SlimSAM), fix the mask by
|
|
8262
8286
|
* hand with the wand, brush and lasso of hackbuild-ui maskEditor (x swaps
|
|
8263
8287
|
* add and erase, [ and ] size the brush, ctrl z undoes), zoom and fit, and
|
|
@@ -8301,6 +8325,10 @@ function thumbOf(img) {
|
|
|
8301
8325
|
t.getContext("2d")?.drawImage(c, 0, 0, t.width, t.height);
|
|
8302
8326
|
return t.toDataURL("image/png");
|
|
8303
8327
|
}
|
|
8328
|
+
/**
|
|
8329
|
+
* Mounts a mask studio on a host: drop or open an image, then cut masks with the point, wand, brush
|
|
8330
|
+
* and lasso tools or a segment model.
|
|
8331
|
+
*/
|
|
8304
8332
|
function mountMaskStudio(host, o = {}) {
|
|
8305
8333
|
let models = o.models ?? {};
|
|
8306
8334
|
const l = listeners();
|
|
@@ -8692,9 +8720,29 @@ function pickSheet(pick) {
|
|
|
8692
8720
|
}
|
|
8693
8721
|
};
|
|
8694
8722
|
}
|
|
8723
|
+
const FILLER = /^(instruct|chat|it|mlc|onnx|gguf|hf|q\d\w*|f16|f32|fp16|int8|bf16|uniform)$/i;
|
|
8724
|
+
/**
|
|
8725
|
+
* A model name cut for the bar chip: filler words (instruct, chat, quant tags)
|
|
8726
|
+
* go, and a name of more than three words keeps its first two and its last,
|
|
8727
|
+
* which is usually the size: "hermes 3 llama 3.2 3b" reads "hermes 3 3b".
|
|
8728
|
+
* A note in brackets goes first: "slimsam 77 uniform (point prompts)" reads "slimsam 77".
|
|
8729
|
+
*/
|
|
8730
|
+
function shortName(name) {
|
|
8731
|
+
const w = name.replace(/\s*\([^)]*\)/g, "").split(/\s+/).filter((x) => x && !FILLER.test(x));
|
|
8732
|
+
return (w.length > 3 ? [
|
|
8733
|
+
w[0],
|
|
8734
|
+
w[1],
|
|
8735
|
+
w[w.length - 1]
|
|
8736
|
+
] : w).join(" ") || name;
|
|
8737
|
+
}
|
|
8738
|
+
/** The chip's words: the short name, then the download size, or the state once it moves. */
|
|
8695
8739
|
function chipWords(s) {
|
|
8696
|
-
const
|
|
8697
|
-
|
|
8740
|
+
const r = s.row;
|
|
8741
|
+
if (!r) return s.empty;
|
|
8742
|
+
const w = $r(r, s.empty);
|
|
8743
|
+
const name = shortName(r.name);
|
|
8744
|
+
if ((r.state === "loading" || r.state === "loaded" || r.state === "error") && w.state) return `${name}, ${w.state}`;
|
|
8745
|
+
return `${name}, ${r.noDownload ? "no download" : r.size ?? "size unknown"}`;
|
|
8698
8746
|
}
|
|
8699
8747
|
/** The closed picker over a host; pressing it opens the sheet. */
|
|
8700
8748
|
function mountModelSelect(host, pick, o = {}) {
|
|
@@ -8704,7 +8752,8 @@ function mountModelSelect(host, pick, o = {}) {
|
|
|
8704
8752
|
if (o.variant === "chip") {
|
|
8705
8753
|
const draw = (s) => {
|
|
8706
8754
|
const words = chipWords(s);
|
|
8707
|
-
|
|
8755
|
+
const full = s.row ? `model: ${s.row.name}${s.row.size ? `, ${s.row.size}` : ""}${$r(s.row, s.empty).state ? `, ${$r(s.row, s.empty).state}` : ""}` : `model: ${s.empty}`;
|
|
8756
|
+
host.innerHTML = `<button type="button" class="hb-msel-chip${s.row?.state ? ` is-${s.row.state}` : ""}" aria-haspopup="dialog" aria-label="${esc(full)}" title="${esc(full)}"><span>${esc(words)}</span></button>`;
|
|
8708
8757
|
};
|
|
8709
8758
|
l.on(host, "click", (e) => {
|
|
8710
8759
|
if (e.target.closest(".hb-msel-chip")) sheet.open();
|
|
@@ -8764,11 +8813,11 @@ function mountModelJobs(host, jobs, o = {}) {
|
|
|
8764
8813
|
}
|
|
8765
8814
|
// packages/ai-views/src/mount-transcribe.ts
|
|
8766
8815
|
/**
|
|
8767
|
-
* TranscribeDrop, TranscriptView and their rack parts in the DOM
|
|
8768
|
-
* earlier transcription tool: the drop zone is the page until a file is in
|
|
8816
|
+
* TranscribeDrop, TranscriptView and their rack parts in the DOM: the drop zone is the page until a file is in
|
|
8769
8817
|
* it, then the transcript is. Lines carry their time, edit in place (one
|
|
8770
8818
|
* undo step each), and export as txt, srt, vtt and json once there is text.
|
|
8771
8819
|
*/
|
|
8820
|
+
/** The HTML of one channel's transcript, or an empty note when there is none. */
|
|
8772
8821
|
function transcriptHtml(c, o = {}) {
|
|
8773
8822
|
if (!c) return `<p class="hb-lay-empty-note">nothing yet. drop a file.</p>`;
|
|
8774
8823
|
const st = di(c.status);
|
|
@@ -8925,8 +8974,7 @@ function mountTranscriptExports(host, queue, o = {}) {
|
|
|
8925
8974
|
}
|
|
8926
8975
|
// packages/ai-views/src/transcribe.ts
|
|
8927
8976
|
/**
|
|
8928
|
-
* The state behind TranscribeDrop and TranscriptView,
|
|
8929
|
-
* transcription tool: drop files, they queue as channels, run one at a
|
|
8977
|
+
* The state behind TranscribeDrop and TranscriptView: drop files, they queue as channels, run one at a
|
|
8930
8978
|
* time, and each becomes a transcript with timestamps that a person can
|
|
8931
8979
|
* edit (with undo) and export as txt, srt, vtt or json. The engine is a
|
|
8932
8980
|
* function the page passes, so a stub runs the view with no weights.
|
|
@@ -8937,6 +8985,7 @@ const TYPES = {
|
|
|
8937
8985
|
vtt: "text/vtt",
|
|
8938
8986
|
json: "application/json"
|
|
8939
8987
|
};
|
|
8988
|
+
/** Creates a transcribe queue that runs each file through `run`, one at a time. */
|
|
8940
8989
|
function transcribeQueue(o) {
|
|
8941
8990
|
let run = o.run;
|
|
8942
8991
|
let channels = [];
|
|
@@ -9140,6 +9189,7 @@ function transcribeQueue(o) {
|
|
|
9140
9189
|
// packages/ai-views/src/memory.ts
|
|
9141
9190
|
const n3 = (x) => Number.isFinite(x) ? x.toFixed(3) : "none";
|
|
9142
9191
|
const rank = (r) => r >= 0 ? `#${r + 1}` : "none";
|
|
9192
|
+
/** The rows of a recall trace as text, marking the hits handed to the model. */
|
|
9143
9193
|
function traceRows(r, maxText = 80) {
|
|
9144
9194
|
const used = new Set(r.hits.map((h) => h.item.id));
|
|
9145
9195
|
return r.trace.map((t, i) => ({
|
|
@@ -9154,11 +9204,13 @@ function traceRows(r, maxText = 80) {
|
|
|
9154
9204
|
used: used.has(t.id)
|
|
9155
9205
|
}));
|
|
9156
9206
|
}
|
|
9207
|
+
/** The HTML of a recall trace table, or an empty note before any recall. */
|
|
9157
9208
|
function inspectorHtml(rec) {
|
|
9158
9209
|
if (!rec) return `<p class="hb-lay-empty-note">no recall yet. ask something to see what memory finds.</p>`;
|
|
9159
9210
|
const rows = traceRows(rec);
|
|
9160
9211
|
return `<p class="hb-lay-empty-note" role="status">"${esc(rec.query)}", ${esc(rec.mode)} recall, ${rows.length} found, ${rows.filter((x) => x.used).length} used.</p><div class="hb-scroll-x" data-ux="detail"><table class="hb-table"><thead><tr><th class="num">#</th><th>kind</th><th>text</th><th>bm25</th><th>cosine</th><th class="num">rrf</th><th class="num">score</th></tr></thead><tbody>` + 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("") + `</tbody></table></div>`;
|
|
9161
9212
|
}
|
|
9213
|
+
/** Shows a recall trace as a table on a host. */
|
|
9162
9214
|
function mountMemoryInspector(host, rec = null) {
|
|
9163
9215
|
host.innerHTML = inspectorHtml(rec);
|
|
9164
9216
|
return {
|
|
@@ -9539,4 +9591,4 @@ function define(prefix = "", registry, Base) {
|
|
|
9539
9591
|
return tag;
|
|
9540
9592
|
});
|
|
9541
9593
|
}
|
|
9542
|
-
export { ELEMENT_NAMES, define, gateWords, mountCameraFeed, mountChatList, mountChatPane, mountComposer, mountContextMeter, mountFrameView, mountMaskRack, mountMaskStudio, mountMaskTools, mountMaskVerbs, mountMemoryInspector, mountModelJobs, mountModelSelect, mountTranscribeDrop, mountTranscribeQueue, mountTranscriptExports, mountTranscriptView, pickSheet, transcriptHtml, turnHtml };
|
|
9594
|
+
export { ELEMENT_NAMES, chipWords, define, gateWords, mountCameraFeed, mountChatList, mountChatPane, mountComposer, mountContextMeter, mountFrameView, mountMaskRack, mountMaskStudio, mountMaskTools, mountMaskVerbs, mountMemoryInspector, mountModelJobs, mountModelSelect, mountTranscribeDrop, mountTranscribeQueue, mountTranscriptExports, mountTranscriptView, pickSheet, shortName, transcriptHtml, turnHtml };
|