@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/mount-model.d.ts
CHANGED
|
@@ -6,17 +6,27 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type ModelRow } from "@virgilvox/hackbuild-ui/vanilla";
|
|
8
8
|
import { type Mounted } from "./dom.js";
|
|
9
|
-
import type { JobsPick, ModelPick } from "./pick.js";
|
|
9
|
+
import type { JobsPick, ModelPick, PickSnapshot } from "./pick.js";
|
|
10
10
|
/** The sheet of one pick, in a drawer on the body. Opens on `open()`. */
|
|
11
11
|
export declare function pickSheet(pick: ModelPick): Mounted & {
|
|
12
12
|
open(): void;
|
|
13
13
|
};
|
|
14
|
+
/** Options for `mountModelSelect`: the one line or the chip variant, and whether to draw the load button. */
|
|
14
15
|
export interface ModelSelectOptions {
|
|
15
16
|
/** "line" (default): the one line and the pink load. "chip": the one model chip of the bar. */
|
|
16
17
|
variant?: "line" | "chip";
|
|
17
18
|
/** Draw the pink load. Off on a gate, whose own button is the pink action. */
|
|
18
19
|
go?: boolean;
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A model name cut for the bar chip: filler words (instruct, chat, quant tags)
|
|
23
|
+
* go, and a name of more than three words keeps its first two and its last,
|
|
24
|
+
* which is usually the size: "hermes 3 llama 3.2 3b" reads "hermes 3 3b".
|
|
25
|
+
* A note in brackets goes first: "slimsam 77 uniform (point prompts)" reads "slimsam 77".
|
|
26
|
+
*/
|
|
27
|
+
export declare function shortName(name: string): string;
|
|
28
|
+
/** The chip's words: the short name, then the download size, or the state once it moves. */
|
|
29
|
+
export declare function chipWords(s: PickSnapshot): string;
|
|
20
30
|
/** The closed picker over a host; pressing it opens the sheet. */
|
|
21
31
|
export declare function mountModelSelect(host: HTMLElement, pick: ModelPick, o?: ModelSelectOptions): Mounted;
|
|
22
32
|
/** The words of a gate's one pink button for a pick: "load, 1.7 gb", then "ready". */
|
package/dist/mount-model.js
CHANGED
|
@@ -39,9 +39,29 @@ export function pickSheet(pick) {
|
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// words a model name carries that say nothing to a person choosing it
|
|
43
|
+
const FILLER = /^(instruct|chat|it|mlc|onnx|gguf|hf|q\d\w*|f16|f32|fp16|int8|bf16|uniform)$/i;
|
|
44
|
+
/**
|
|
45
|
+
* A model name cut for the bar chip: filler words (instruct, chat, quant tags)
|
|
46
|
+
* go, and a name of more than three words keeps its first two and its last,
|
|
47
|
+
* which is usually the size: "hermes 3 llama 3.2 3b" reads "hermes 3 3b".
|
|
48
|
+
* A note in brackets goes first: "slimsam 77 uniform (point prompts)" reads "slimsam 77".
|
|
49
|
+
*/
|
|
50
|
+
export function shortName(name) {
|
|
51
|
+
const w = name.replace(/\s*\([^)]*\)/g, "").split(/\s+/).filter((x) => x && !FILLER.test(x));
|
|
52
|
+
const kept = w.length > 3 ? [w[0], w[1], w[w.length - 1]] : w;
|
|
53
|
+
return kept.join(" ") || name;
|
|
54
|
+
}
|
|
55
|
+
/** The chip's words: the short name, then the download size, or the state once it moves. */
|
|
56
|
+
export function chipWords(s) {
|
|
57
|
+
const r = s.row;
|
|
58
|
+
if (!r)
|
|
59
|
+
return s.empty;
|
|
60
|
+
const w = lineWords(r, s.empty);
|
|
61
|
+
const name = shortName(r.name);
|
|
62
|
+
if ((r.state === "loading" || r.state === "loaded" || r.state === "error") && w.state)
|
|
63
|
+
return `${name}, ${w.state}`;
|
|
64
|
+
return `${name}, ${r.noDownload ? "no download" : r.size ?? "size unknown"}`;
|
|
45
65
|
}
|
|
46
66
|
/** The closed picker over a host; pressing it opens the sheet. */
|
|
47
67
|
export function mountModelSelect(host, pick, o = {}) {
|
|
@@ -51,7 +71,8 @@ export function mountModelSelect(host, pick, o = {}) {
|
|
|
51
71
|
if (o.variant === "chip") {
|
|
52
72
|
const draw = (s) => {
|
|
53
73
|
const words = chipWords(s);
|
|
54
|
-
|
|
74
|
+
const full = s.row ? `model: ${s.row.name}${s.row.size ? `, ${s.row.size}` : ""}${lineWords(s.row, s.empty).state ? `, ${lineWords(s.row, s.empty).state}` : ""}` : `model: ${s.empty}`;
|
|
75
|
+
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>`;
|
|
55
76
|
};
|
|
56
77
|
l.on(host, "click", (e) => {
|
|
57
78
|
if (e.target.closest(".hb-msel-chip"))
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TranscribeDrop, TranscriptView and their rack parts in the DOM
|
|
3
|
-
* earlier transcription tool: the drop zone is the page until a file is in
|
|
2
|
+
* TranscribeDrop, TranscriptView and their rack parts in the DOM: the drop zone is the page until a file is in
|
|
4
3
|
* it, then the transcript is. Lines carry their time, edit in place (one
|
|
5
4
|
* undo step each), and export as txt, srt, vtt and json once there is text.
|
|
6
5
|
*/
|
|
7
6
|
import { type Mounted } from "./dom.js";
|
|
8
7
|
import type { Channel, TranscribeQueue } from "./transcribe.js";
|
|
8
|
+
/**
|
|
9
|
+
* Options for a transcript: speaker fields, a seek callback for the times, and whether dropped
|
|
10
|
+
* lines show in place.
|
|
11
|
+
*/
|
|
9
12
|
export interface TranscriptViewOptions {
|
|
10
13
|
/** Speaker fields beside each line. Off by default: they are inputs, and a subject keeps few controls. */
|
|
11
14
|
speakers?: boolean;
|
|
@@ -14,9 +17,14 @@ export interface TranscriptViewOptions {
|
|
|
14
17
|
/** Show dropped lines in place. */
|
|
15
18
|
showDropped?: boolean;
|
|
16
19
|
}
|
|
20
|
+
/** The HTML of one channel's transcript, or an empty note when there is none. */
|
|
17
21
|
export declare function transcriptHtml(c: Channel | undefined, o?: TranscriptViewOptions): string;
|
|
18
22
|
/** The selected channel's transcript over a host. */
|
|
19
23
|
export declare function mountTranscriptView(host: HTMLElement, queue: TranscribeQueue, o?: TranscriptViewOptions): Mounted;
|
|
24
|
+
/**
|
|
25
|
+
* Options for `mountTranscribeDrop`: accepted types, empty state words and a sample button, plus
|
|
26
|
+
* the transcript view options.
|
|
27
|
+
*/
|
|
20
28
|
export interface TranscribeDropOptions extends TranscriptViewOptions {
|
|
21
29
|
accept?: string;
|
|
22
30
|
title?: string;
|
|
@@ -26,6 +34,7 @@ export interface TranscribeDropOptions extends TranscriptViewOptions {
|
|
|
26
34
|
sampleLabel?: string;
|
|
27
35
|
onSample?: () => void;
|
|
28
36
|
}
|
|
37
|
+
/** A mounted drop zone whose `pick` opens the file picker. */
|
|
29
38
|
export interface TranscribeDropHandle extends Mounted {
|
|
30
39
|
/** Open the file picker: the add files verb. */
|
|
31
40
|
pick(): void;
|
package/dist/mount-transcribe.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TranscribeDrop, TranscriptView and their rack parts in the DOM
|
|
3
|
-
* earlier transcription tool: the drop zone is the page until a file is in
|
|
2
|
+
* TranscribeDrop, TranscriptView and their rack parts in the DOM: the drop zone is the page until a file is in
|
|
4
3
|
* it, then the transcript is. Lines carry their time, edit in place (one
|
|
5
4
|
* undo step each), and export as txt, srt, vtt and json once there is text.
|
|
6
5
|
*/
|
|
7
6
|
import { clockTime, droppedLine, stripStatus } from "@virgilvox/hackbuild-ui/vanilla";
|
|
8
7
|
import { ICON, download, esc, listeners, show } from "./dom.js";
|
|
8
|
+
/** The HTML of one channel's transcript, or an empty note when there is none. */
|
|
9
9
|
export function transcriptHtml(c, o = {}) {
|
|
10
10
|
if (!c)
|
|
11
11
|
return `<p class="hb-lay-empty-note">nothing yet. drop a file.</p>`;
|
package/dist/pick.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { ModelRecord, StorageEstimate } from "@hackbuild/models";
|
|
|
10
10
|
import { type WeightStore } from "@hackbuild/weights";
|
|
11
11
|
import { type ModelOption, type ModelRow, type OwnKind } from "@virgilvox/hackbuild-ui/vanilla";
|
|
12
12
|
import { type Job } from "./jobs.js";
|
|
13
|
+
/** What a loader gets: an abort signal, a progress callback and the row's options. */
|
|
13
14
|
export interface LoadContext {
|
|
14
15
|
signal: AbortSignal;
|
|
15
16
|
/** 0 to 1, or null while the total is unknown. */
|
|
@@ -26,9 +27,17 @@ export type Loader = (rec: ModelRecord, ctx: LoadContext) => Promise<unknown>;
|
|
|
26
27
|
*/
|
|
27
28
|
/** The cache keys of a record's files in a weight store, as weightsLoader writes them. */
|
|
28
29
|
export declare function weightKeys(rec: ModelRecord): string[];
|
|
30
|
+
/**
|
|
31
|
+
* A loader that fetches a record's weight files through a weight store; records that load through
|
|
32
|
+
* their runtime throw.
|
|
33
|
+
*/
|
|
29
34
|
export declare function weightsLoader(store: WeightStore): Loader;
|
|
30
35
|
/** Deletes a stored model's files from a weight store: the remove of a picker. */
|
|
31
36
|
export declare function weightsRemover(store: WeightStore): (rec: ModelRecord) => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Options for `useModelPick`: records, env, storage estimate, loader, remover, stored ids, the
|
|
39
|
+
* chosen id and extra row options.
|
|
40
|
+
*/
|
|
32
41
|
export interface PickOptions {
|
|
33
42
|
/** Records to pick from; default every record the views know. */
|
|
34
43
|
records?: readonly ModelRecord[];
|
|
@@ -44,6 +53,7 @@ export interface PickOptions {
|
|
|
44
53
|
/** Options a job adds to every row, like a language select for speech. */
|
|
45
54
|
extra?: (rec: ModelRecord) => readonly ModelOption[];
|
|
46
55
|
}
|
|
56
|
+
/** What a picker shows: its job, title, rows, the chosen id and row, and what the loader returned for it. */
|
|
47
57
|
export interface PickSnapshot {
|
|
48
58
|
job: Job;
|
|
49
59
|
title: string;
|
|
@@ -54,6 +64,10 @@ export interface PickSnapshot {
|
|
|
54
64
|
/** What the loader returned for the chosen model, once it is loaded (an engine, a session). */
|
|
55
65
|
loaded: unknown;
|
|
56
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* A model picker for one job: choose, load, cancel, remove, set row options, add your own model,
|
|
69
|
+
* and subscribe to its snapshot.
|
|
70
|
+
*/
|
|
57
71
|
export interface ModelPick {
|
|
58
72
|
readonly job: Job;
|
|
59
73
|
snapshot(): PickSnapshot;
|
|
@@ -91,6 +105,7 @@ export declare function ownRecord(job: Job, kind: OwnKind, v: Record<string, str
|
|
|
91
105
|
* that fits, else the first.
|
|
92
106
|
*/
|
|
93
107
|
export declare function defaultPick(records: readonly ModelRecord[], env?: Env, estimate?: StorageEstimate | null): string;
|
|
108
|
+
/** Creates a model picker for a job, with rows that say whether each model fits this machine. */
|
|
94
109
|
export declare function useModelPick(job: Job, o?: PickOptions): ModelPick;
|
|
95
110
|
/** A preset for a tool with several jobs: one pick per job. */
|
|
96
111
|
export interface PickPreset {
|
|
@@ -98,6 +113,7 @@ export interface PickPreset {
|
|
|
98
113
|
label: string;
|
|
99
114
|
picks: Partial<Record<Job, string>>;
|
|
100
115
|
}
|
|
116
|
+
/** One line of a jobs rack: the job, its label, whether it is required, and the chosen row. */
|
|
101
117
|
export interface JobLine {
|
|
102
118
|
job: Job;
|
|
103
119
|
label: string;
|
|
@@ -125,6 +141,7 @@ export interface JobsPick {
|
|
|
125
141
|
update(o: Parameters<ModelPick["update"]>[0]): void;
|
|
126
142
|
setPresets(p: readonly PickPreset[]): void;
|
|
127
143
|
}
|
|
144
|
+
/** Creates one picker per job and joins them as a rack with presets and load all. */
|
|
128
145
|
export declare function useJobsPick(jobs: readonly {
|
|
129
146
|
job: Job;
|
|
130
147
|
required?: boolean;
|
package/dist/pick.js
CHANGED
|
@@ -24,6 +24,10 @@ export function weightKeys(rec) {
|
|
|
24
24
|
const files = s.files?.length ? s.files.map((f) => f.path) : s.file ? [s.file] : [];
|
|
25
25
|
return base ? files.map((f) => base + f) : [];
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A loader that fetches a record's weight files through a weight store; records that load through
|
|
29
|
+
* their runtime throw.
|
|
30
|
+
*/
|
|
27
31
|
export function weightsLoader(store) {
|
|
28
32
|
return async (rec, { signal, onProgress }) => {
|
|
29
33
|
if (rec.noDownload || rec.sizeMB === 0) {
|
|
@@ -74,6 +78,7 @@ export function defaultPick(records, env, estimate) {
|
|
|
74
78
|
const fits = records.filter((r) => rowOf(r, { env, estimate }).unfit === undefined);
|
|
75
79
|
return (fits.find((r) => r.group === "start here") ?? fits.find((r) => r.speed === "fast" || r.speed === "steady") ?? fits[0] ?? records[0])?.id ?? "";
|
|
76
80
|
}
|
|
81
|
+
/** Creates a model picker for a job, with rows that say whether each model fits this machine. */
|
|
77
82
|
export function useModelPick(job, o = {}) {
|
|
78
83
|
const def = JOBS[job];
|
|
79
84
|
let records = jobRecords(job, o.records ?? ALL_RECORDS);
|
|
@@ -207,6 +212,7 @@ export function useModelPick(job, o = {}) {
|
|
|
207
212
|
};
|
|
208
213
|
return pick;
|
|
209
214
|
}
|
|
215
|
+
/** Creates one picker per job and joins them as a rack with presets and load all. */
|
|
210
216
|
export function useJobsPick(jobs, initialPresets = [], shared = {}) {
|
|
211
217
|
let presets = initialPresets;
|
|
212
218
|
const extra = new Set();
|
package/dist/rows.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import type { Env } from "@hackbuild/ai-env";
|
|
7
7
|
import { type ModelRecord, type StorageEstimate } from "@hackbuild/models";
|
|
8
8
|
import { type ModelBackend, type ModelOption, type ModelPickState, type ModelRow, type ModelRowGroup } from "@virgilvox/hackbuild-ui/vanilla";
|
|
9
|
+
/** Whether a record has nothing to download: a built in, system or zero size model. */
|
|
9
10
|
export declare function isNoDownload(r: ModelRecord): boolean;
|
|
11
|
+
/** Whether a record's censorship is "uncensored" or "abliterated". */
|
|
10
12
|
export declare function isUncensored(r: ModelRecord): boolean;
|
|
11
13
|
/** The group a row sits in. A model on this machine leads; else the record's group, else by size. */
|
|
12
14
|
export declare function groupOf(r: ModelRecord, state?: ModelPickState): ModelRowGroup;
|
|
@@ -21,6 +23,10 @@ export declare function detailOf(r: ModelRecord): {
|
|
|
21
23
|
}[];
|
|
22
24
|
/** The options a chosen row offers: backend when the ladder has gpu and cpu, quant when it has several, context for chat. */
|
|
23
25
|
export declare function optionsOf(r: ModelRecord, values?: Record<string, string>, extra?: readonly ModelOption[]): ModelOption[];
|
|
26
|
+
/**
|
|
27
|
+
* What a row needs beyond its record: env, storage estimate, load state and progress, option
|
|
28
|
+
* values, job options, and whether the person added it.
|
|
29
|
+
*/
|
|
24
30
|
export interface RowContext {
|
|
25
31
|
env?: Env | undefined;
|
|
26
32
|
estimate?: StorageEstimate | null | undefined;
|
package/dist/rows.js
CHANGED
|
@@ -17,9 +17,11 @@ const GROUPS = {
|
|
|
17
17
|
"no download": "none",
|
|
18
18
|
own: "own",
|
|
19
19
|
};
|
|
20
|
+
/** Whether a record has nothing to download: a built in, system or zero size model. */
|
|
20
21
|
export function isNoDownload(r) {
|
|
21
22
|
return !!r.noDownload || r.sizeMB === 0 || r.provider === "prompt-api" || r.provider === "system";
|
|
22
23
|
}
|
|
24
|
+
/** Whether a record's censorship is "uncensored" or "abliterated". */
|
|
23
25
|
export function isUncensored(r) {
|
|
24
26
|
return r.censorship === "uncensored" || r.censorship === "abliterated";
|
|
25
27
|
}
|