@hackbuild/ai-views 0.1.1 → 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 +25 -5
- package/dist/elements.d.ts +1 -1
- package/dist/elements.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/loaders.d.ts +100 -0
- package/dist/loaders.js +308 -0
- package/dist/mount-model.d.ts +10 -1
- package/dist/mount-model.js +25 -4
- package/dist/single/elements.iife.js +26 -3
- package/dist/single/elements.js +25 -4
- package/dist/single/index.iife.js +17032 -6187
- package/dist/single/index.js +17030 -6188
- package/dist/single/vue.iife.js +24 -3
- package/dist/single/vue.js +24 -3
- package/llms.md +100 -0
- package/package.json +3 -1
package/dist/single/vue.iife.js
CHANGED
|
@@ -9852,9 +9852,29 @@ Component that was made reactive: `, type);
|
|
|
9852
9852
|
}
|
|
9853
9853
|
};
|
|
9854
9854
|
}
|
|
9855
|
+
const FILLER = /^(instruct|chat|it|mlc|onnx|gguf|hf|q\d\w*|f16|f32|fp16|int8|bf16|uniform)$/i;
|
|
9856
|
+
/**
|
|
9857
|
+
* A model name cut for the bar chip: filler words (instruct, chat, quant tags)
|
|
9858
|
+
* go, and a name of more than three words keeps its first two and its last,
|
|
9859
|
+
* which is usually the size: "hermes 3 llama 3.2 3b" reads "hermes 3 3b".
|
|
9860
|
+
* A note in brackets goes first: "slimsam 77 uniform (point prompts)" reads "slimsam 77".
|
|
9861
|
+
*/
|
|
9862
|
+
function shortName(name) {
|
|
9863
|
+
const w = name.replace(/\s*\([^)]*\)/g, "").split(/\s+/).filter((x) => x && !FILLER.test(x));
|
|
9864
|
+
return (w.length > 3 ? [
|
|
9865
|
+
w[0],
|
|
9866
|
+
w[1],
|
|
9867
|
+
w[w.length - 1]
|
|
9868
|
+
] : w).join(" ") || name;
|
|
9869
|
+
}
|
|
9870
|
+
/** The chip's words: the short name, then the download size, or the state once it moves. */
|
|
9855
9871
|
function chipWords(s) {
|
|
9856
|
-
const
|
|
9857
|
-
|
|
9872
|
+
const r = s.row;
|
|
9873
|
+
if (!r) return s.empty;
|
|
9874
|
+
const w = $r(r, s.empty);
|
|
9875
|
+
const name = shortName(r.name);
|
|
9876
|
+
if ((r.state === "loading" || r.state === "loaded" || r.state === "error") && w.state) return `${name}, ${w.state}`;
|
|
9877
|
+
return `${name}, ${r.noDownload ? "no download" : r.size ?? "size unknown"}`;
|
|
9858
9878
|
}
|
|
9859
9879
|
/** The closed picker over a host; pressing it opens the sheet. */
|
|
9860
9880
|
function mountModelSelect(host, pick, o = {}) {
|
|
@@ -9864,7 +9884,8 @@ Component that was made reactive: `, type);
|
|
|
9864
9884
|
if (o.variant === "chip") {
|
|
9865
9885
|
const draw = (s) => {
|
|
9866
9886
|
const words = chipWords(s);
|
|
9867
|
-
|
|
9887
|
+
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}`;
|
|
9888
|
+
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>`;
|
|
9868
9889
|
};
|
|
9869
9890
|
l.on(host, "click", (e) => {
|
|
9870
9891
|
if (e.target.closest(".hb-msel-chip")) sheet.open();
|
package/dist/single/vue.js
CHANGED
|
@@ -9850,9 +9850,29 @@ function pickSheet(pick) {
|
|
|
9850
9850
|
}
|
|
9851
9851
|
};
|
|
9852
9852
|
}
|
|
9853
|
+
const FILLER = /^(instruct|chat|it|mlc|onnx|gguf|hf|q\d\w*|f16|f32|fp16|int8|bf16|uniform)$/i;
|
|
9854
|
+
/**
|
|
9855
|
+
* A model name cut for the bar chip: filler words (instruct, chat, quant tags)
|
|
9856
|
+
* go, and a name of more than three words keeps its first two and its last,
|
|
9857
|
+
* which is usually the size: "hermes 3 llama 3.2 3b" reads "hermes 3 3b".
|
|
9858
|
+
* A note in brackets goes first: "slimsam 77 uniform (point prompts)" reads "slimsam 77".
|
|
9859
|
+
*/
|
|
9860
|
+
function shortName(name) {
|
|
9861
|
+
const w = name.replace(/\s*\([^)]*\)/g, "").split(/\s+/).filter((x) => x && !FILLER.test(x));
|
|
9862
|
+
return (w.length > 3 ? [
|
|
9863
|
+
w[0],
|
|
9864
|
+
w[1],
|
|
9865
|
+
w[w.length - 1]
|
|
9866
|
+
] : w).join(" ") || name;
|
|
9867
|
+
}
|
|
9868
|
+
/** The chip's words: the short name, then the download size, or the state once it moves. */
|
|
9853
9869
|
function chipWords(s) {
|
|
9854
|
-
const
|
|
9855
|
-
|
|
9870
|
+
const r = s.row;
|
|
9871
|
+
if (!r) return s.empty;
|
|
9872
|
+
const w = $r(r, s.empty);
|
|
9873
|
+
const name = shortName(r.name);
|
|
9874
|
+
if ((r.state === "loading" || r.state === "loaded" || r.state === "error") && w.state) return `${name}, ${w.state}`;
|
|
9875
|
+
return `${name}, ${r.noDownload ? "no download" : r.size ?? "size unknown"}`;
|
|
9856
9876
|
}
|
|
9857
9877
|
/** The closed picker over a host; pressing it opens the sheet. */
|
|
9858
9878
|
function mountModelSelect(host, pick, o = {}) {
|
|
@@ -9862,7 +9882,8 @@ function mountModelSelect(host, pick, o = {}) {
|
|
|
9862
9882
|
if (o.variant === "chip") {
|
|
9863
9883
|
const draw = (s) => {
|
|
9864
9884
|
const words = chipWords(s);
|
|
9865
|
-
|
|
9885
|
+
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}`;
|
|
9886
|
+
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>`;
|
|
9866
9887
|
};
|
|
9867
9888
|
l.on(host, "click", (e) => {
|
|
9868
9889
|
if (e.target.closest(".hb-msel-chip")) sheet.open();
|
package/llms.md
CHANGED
|
@@ -66,6 +66,12 @@ interface ChatPaneOptions {
|
|
|
66
66
|
|
|
67
67
|
Options for `mountChatPane`: the reply's name and the empty state's words.
|
|
68
68
|
|
|
69
|
+
```ts
|
|
70
|
+
function chipWords(s: PickSnapshot): string
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The chip's words: the short name, then the download size, or the state once it moves.
|
|
74
|
+
|
|
69
75
|
```ts
|
|
70
76
|
interface ComposerOptions {
|
|
71
77
|
label?: string;
|
|
@@ -334,6 +340,12 @@ function pickSheet(pick: ModelPick): Mounted & { open(): void }
|
|
|
334
340
|
|
|
335
341
|
The sheet of one pick, in a drawer on the body.
|
|
336
342
|
|
|
343
|
+
```ts
|
|
344
|
+
function shortName(name: string): string
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
A model name cut for the bar chip: filler words (instruct, chat, quant tags) go, and a name of more than three words keeps its first two and its last, which is usually the size: "hermes 3 llama 3.2 3b" reads "hermes 3 3b".
|
|
348
|
+
|
|
337
349
|
```ts
|
|
338
350
|
interface StudioState {
|
|
339
351
|
busy: string;
|
|
@@ -417,6 +429,18 @@ const ALL_RECORDS: readonly ModelRecord[]
|
|
|
417
429
|
|
|
418
430
|
Every record the views know, the running package's copy of a duplicate first.
|
|
419
431
|
|
|
432
|
+
```ts
|
|
433
|
+
function asImage(img: unknown): unknown
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Pixels ({ width, height, data }) as a canvas, which every runtime reads; anything else passes through.
|
|
437
|
+
|
|
438
|
+
```ts
|
|
439
|
+
type AskFn = (image: unknown, question?: string) => Promise<string>
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
A vision language model as a page calls it: a question about an image (a caption without one), answered in words.
|
|
443
|
+
|
|
420
444
|
```ts
|
|
421
445
|
function backendOf(r: ModelRecord, env?: Env): ModelBackend
|
|
422
446
|
```
|
|
@@ -523,12 +547,24 @@ function defaultPick(records: readonly ModelRecord[], env?: Env, estimate?: Stor
|
|
|
523
547
|
|
|
524
548
|
The row a picker starts on: the first "start here" record that fits this machine, else the first that fits and is fast or steady, else the first that fits, else the first.
|
|
525
549
|
|
|
550
|
+
```ts
|
|
551
|
+
type DepthFn = (image: unknown) => Promise<{ data: Float32Array; height: number; width: number }>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
A depth model as a page calls it: 0 to 1 per pixel, larger is nearer (relative inverse depth).
|
|
555
|
+
|
|
526
556
|
```ts
|
|
527
557
|
function detailOf(r: ModelRecord): { label: string; value: string }[]
|
|
528
558
|
```
|
|
529
559
|
|
|
530
560
|
The chevron detail: licence, source, context, quant, runtime, and where the size came from.
|
|
531
561
|
|
|
562
|
+
```ts
|
|
563
|
+
type DetectFn = (image: unknown) => Promise<FrameBox[]>
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
A detector as a page calls it: boxes in image pixels, best first.
|
|
567
|
+
|
|
532
568
|
```ts
|
|
533
569
|
type ExportKind = "txt" | "srt" | "vtt" | "json"
|
|
534
570
|
```
|
|
@@ -593,6 +629,12 @@ function groupOf(r: ModelRecord, state?: ModelPickState): ModelRowGroup
|
|
|
593
629
|
|
|
594
630
|
The group a row sits in.
|
|
595
631
|
|
|
632
|
+
```ts
|
|
633
|
+
type ImageJob = ImageGenerator & { tokenize: ClipTokenize; make(o: FormOptions): Promise<Generated> }
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
An image model with its CLIP tokenizer: `make` generates with the form's defaults filled in.
|
|
637
|
+
|
|
596
638
|
```ts
|
|
597
639
|
function inspectorHtml(rec: RecallLike | null): string
|
|
598
640
|
```
|
|
@@ -651,6 +693,25 @@ interface JobLine {
|
|
|
651
693
|
|
|
652
694
|
One line of a jobs rack: the job, its label, whether it is required, and the chosen row.
|
|
653
695
|
|
|
696
|
+
```ts
|
|
697
|
+
function jobLoader<J extends Job>(job: J, o?: JobLoaderOptions): Loader
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
A real Loader for a job.
|
|
701
|
+
|
|
702
|
+
```ts
|
|
703
|
+
interface JobLoaderOptions {
|
|
704
|
+
allowGplPhonemizer?: boolean;
|
|
705
|
+
env?: Env;
|
|
706
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
707
|
+
modules?: RuntimeModules;
|
|
708
|
+
rng?: () => number;
|
|
709
|
+
store?: WeightStore | Promise<WeightStore>;
|
|
710
|
+
}
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
Options for jobLoader.
|
|
714
|
+
|
|
654
715
|
```ts
|
|
655
716
|
function jobRecords(job: Job, records?: readonly ModelRecord[]): ModelRecord[]
|
|
656
717
|
```
|
|
@@ -679,6 +740,24 @@ interface JobsPick {
|
|
|
679
740
|
|
|
680
741
|
Several pickers as one rack: a line per job, presets with their totals, and load all.
|
|
681
742
|
|
|
743
|
+
```ts
|
|
744
|
+
interface JobValues {
|
|
745
|
+
chat: ChatEngine;
|
|
746
|
+
depth: DepthFn;
|
|
747
|
+
detect: DetectFn;
|
|
748
|
+
embed: Embedder;
|
|
749
|
+
faceswap: unknown;
|
|
750
|
+
image: ImageJob;
|
|
751
|
+
landmarks: unknown;
|
|
752
|
+
masks: MaskModels;
|
|
753
|
+
transcribe: Transcriber;
|
|
754
|
+
vision: AskFn;
|
|
755
|
+
voice: Engine;
|
|
756
|
+
}
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
What a jobLoader load resolves to, per job: chat a ChatEngine; transcribe a Transcriber; detect a DetectFn; masks MaskModels; depth a DepthFn; vision an AskFn; image an ImageJob; voice a loaded @hackbuild/speak Engine; embed an Embedder.
|
|
760
|
+
|
|
682
761
|
```ts
|
|
683
762
|
function labelColour(label: string | undefined, palette: readonly string[]): string
|
|
684
763
|
```
|
|
@@ -847,6 +926,27 @@ interface RunResult {
|
|
|
847
926
|
|
|
848
927
|
What a transcriber returns: segments, dropped lines, duration, language and model.
|
|
849
928
|
|
|
929
|
+
```ts
|
|
930
|
+
const RUNTIME_URLS: { readonly bellows: readonly ["https://cdn.jsdelivr.net/npm/bellows-voice@0.8.0/engine/+esm"]; readonly kokoro: readonly ["https://cdn.jsdelivr.net/npm/kokoro-js@1.2.1/+esm"]; readonly webllm: readonly ["https://esm.run/@mlc-ai/web-llm@0.2.84", "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.84/+esm"] }
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
Pinned CDN modules jobLoader imports at load time.
|
|
934
|
+
|
|
935
|
+
```ts
|
|
936
|
+
interface RuntimeModules {
|
|
937
|
+
bellows?: () => Promise<unknown>;
|
|
938
|
+
dsp?: () => Promise<Dsp>;
|
|
939
|
+
kokoro?: () => Promise<unknown>;
|
|
940
|
+
ort?: () => Promise<OrtModule>;
|
|
941
|
+
tasksVision?: () => Promise<unknown>;
|
|
942
|
+
transformers?: () => Promise<TjsModule>;
|
|
943
|
+
webllm?: () => Promise<unknown>;
|
|
944
|
+
wllama?: () => Promise<unknown>;
|
|
945
|
+
}
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
The runtime modules, each a function that imports it.
|
|
949
|
+
|
|
850
950
|
```ts
|
|
851
951
|
function sizeWords(r: ModelRecord): string | undefined
|
|
852
952
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackbuild/ai-views",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Views that bind the browser AI packages to hackbuild-ui: a model picker per job, a chat pane and composer, a drop first transcriber, a mask studio, a frame view and a camera feed. Each ships as a Vue component and a custom element.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@hackbuild/ai-env": "0.1.2",
|
|
45
|
+
"@hackbuild/audio-dsp": "0.1.2",
|
|
45
46
|
"@hackbuild/chat": "0.1.2",
|
|
47
|
+
"@hackbuild/devices": "0.1.3",
|
|
46
48
|
"@hackbuild/embed": "0.1.3",
|
|
47
49
|
"@hackbuild/imagegen": "0.1.3",
|
|
48
50
|
"@hackbuild/memory": "0.1.3",
|