@missionsquad/browserai 0.1.0
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/LICENSE +15 -0
- package/README.md +229 -0
- package/dist/audio/clip.d.ts +51 -0
- package/dist/audio/clip.d.ts.map +1 -0
- package/dist/audio/clip.js +71 -0
- package/dist/audio/clip.js.map +1 -0
- package/dist/audio/decode.d.ts +7 -0
- package/dist/audio/decode.d.ts.map +1 -0
- package/dist/audio/decode.js +19 -0
- package/dist/audio/decode.js.map +1 -0
- package/dist/audio/pcm.d.ts +13 -0
- package/dist/audio/pcm.d.ts.map +1 -0
- package/dist/audio/pcm.js +66 -0
- package/dist/audio/pcm.js.map +1 -0
- package/dist/audio/recorder.d.ts +40 -0
- package/dist/audio/recorder.d.ts.map +1 -0
- package/dist/audio/recorder.js +127 -0
- package/dist/audio/recorder.js.map +1 -0
- package/dist/audio/streaming-player.d.ts +29 -0
- package/dist/audio/streaming-player.d.ts.map +1 -0
- package/dist/audio/streaming-player.js +82 -0
- package/dist/audio/streaming-player.js.map +1 -0
- package/dist/client.d.ts +195 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +638 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +81 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +52 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +74 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +18 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +43 -0
- package/dist/events.js.map +1 -0
- package/dist/generation.d.ts +12 -0
- package/dist/generation.d.ts.map +1 -0
- package/dist/generation.js +30 -0
- package/dist/generation.js.map +1 -0
- package/dist/hardware.d.ts +23 -0
- package/dist/hardware.d.ts.map +1 -0
- package/dist/hardware.js +150 -0
- package/dist/hardware.js.map +1 -0
- package/dist/history.d.ts +81 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +193 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/inference.d.ts +89 -0
- package/dist/inference.d.ts.map +1 -0
- package/dist/inference.js +411 -0
- package/dist/inference.js.map +1 -0
- package/dist/json.d.ts +22 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +145 -0
- package/dist/json.js.map +1 -0
- package/dist/metrics.d.ts +18 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +59 -0
- package/dist/metrics.js.map +1 -0
- package/dist/model-cache.d.ts +49 -0
- package/dist/model-cache.d.ts.map +1 -0
- package/dist/model-cache.js +511 -0
- package/dist/model-cache.js.map +1 -0
- package/dist/model-source.d.ts +27 -0
- package/dist/model-source.d.ts.map +1 -0
- package/dist/model-source.js +110 -0
- package/dist/model-source.js.map +1 -0
- package/dist/models.d.ts +103 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +1052 -0
- package/dist/models.js.map +1 -0
- package/dist/multimodal.d.ts +261 -0
- package/dist/multimodal.d.ts.map +1 -0
- package/dist/multimodal.js +506 -0
- package/dist/multimodal.js.map +1 -0
- package/dist/prompt.d.ts +13 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +32 -0
- package/dist/prompt.js.map +1 -0
- package/dist/proxy-verify.d.ts +10 -0
- package/dist/proxy-verify.d.ts.map +1 -0
- package/dist/proxy-verify.js +98 -0
- package/dist/proxy-verify.js.map +1 -0
- package/dist/schema-validator.d.ts +6 -0
- package/dist/schema-validator.d.ts.map +1 -0
- package/dist/schema-validator.js +104 -0
- package/dist/schema-validator.js.map +1 -0
- package/dist/schema.d.ts +98 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +115 -0
- package/dist/schema.js.map +1 -0
- package/dist/text-utils.d.ts +8 -0
- package/dist/text-utils.d.ts.map +1 -0
- package/dist/text-utils.js +14 -0
- package/dist/text-utils.js.map +1 -0
- package/dist/voice/helpers.d.ts +35 -0
- package/dist/voice/helpers.d.ts.map +1 -0
- package/dist/voice/helpers.js +49 -0
- package/dist/voice/helpers.js.map +1 -0
- package/dist/voice/voice-pipeline.d.ts +155 -0
- package/dist/voice/voice-pipeline.d.ts.map +1 -0
- package/dist/voice/voice-pipeline.js +407 -0
- package/dist/voice/voice-pipeline.js.map +1 -0
- package/dist/webllm.worker.d.ts +2 -0
- package/dist/webllm.worker.d.ts.map +1 -0
- package/dist/webllm.worker.js +8 -0
- package/dist/webllm.worker.js.map +1 -0
- package/package.json +62 -0
- package/src/audio/clip.ts +94 -0
- package/src/audio/decode.ts +19 -0
- package/src/audio/pcm.ts +62 -0
- package/src/audio/recorder.ts +146 -0
- package/src/audio/streaming-player.ts +99 -0
- package/src/client.ts +784 -0
- package/src/config.ts +104 -0
- package/src/errors.ts +81 -0
- package/src/events.ts +53 -0
- package/src/generation.ts +39 -0
- package/src/hardware.ts +193 -0
- package/src/history.ts +257 -0
- package/src/index.ts +203 -0
- package/src/inference.ts +579 -0
- package/src/json.ts +169 -0
- package/src/metrics.ts +63 -0
- package/src/model-cache.ts +637 -0
- package/src/model-source.ts +142 -0
- package/src/models.ts +1171 -0
- package/src/multimodal.ts +697 -0
- package/src/prompt.ts +33 -0
- package/src/proxy-verify.ts +113 -0
- package/src/schema-validator.ts +117 -0
- package/src/schema.ts +118 -0
- package/src/text-utils.ts +12 -0
- package/src/voice/helpers.ts +59 -0
- package/src/voice/voice-pipeline.ts +513 -0
- package/src/webllm.worker.ts +9 -0
- package/worker-template/README.md +39 -0
- package/worker-template/cloudflare-worker.ts +389 -0
- package/worker-template/wrangler.jsonc +19 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AppConfig, ModelRecord } from "@mlc-ai/web-llm";
|
|
2
|
+
type WebLLMModule = typeof import("@mlc-ai/web-llm");
|
|
3
|
+
export type ModelSourceMode = "direct" | "same-origin-proxy";
|
|
4
|
+
export type BrowserCacheBackend = "cache" | "indexeddb" | "opfs" | "cross-origin";
|
|
5
|
+
/** The Cache API bucket Transformers.js artifacts are cached in (shared with model-cache cleanup). */
|
|
6
|
+
export declare const TRANSFORMERS_CACHE_KEY = "transformers-cache";
|
|
7
|
+
/**
|
|
8
|
+
* Build the WebLLM AppConfig for a load: the bundled prebuilt records merged with the SDK's custom
|
|
9
|
+
* MLC records and curated overrides, optionally rewritten to same-origin proxy routes, with the
|
|
10
|
+
* chosen artifact cache backend applied. `proxyOrigin` is only read in proxy mode.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildWebLLMAppConfig(webllm: WebLLMModule, mode: ModelSourceMode, proxyOrigin: string, cacheBackend: BrowserCacheBackend): AppConfig;
|
|
13
|
+
export declare function withCustomModelRecords(appConfig: AppConfig): AppConfig;
|
|
14
|
+
export declare function buildProxiedAppConfig(appConfig: AppConfig, origin: string): AppConfig;
|
|
15
|
+
export declare function proxyModelRecord(record: ModelRecord, origin: string): ModelRecord;
|
|
16
|
+
export declare function proxyModelLibraryUrl(rawUrl: string, origin: string): string;
|
|
17
|
+
export declare function proxyHuggingFaceUrl(rawUrl: string, origin: string): string;
|
|
18
|
+
export declare function proxyRawGithubUrl(rawUrl: string, origin: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Merge a caller-supplied context length into the selected model's record overrides. Preserves any
|
|
21
|
+
* curated overrides (e.g. Gemma's fixed sliding-window config) by merging rather than replacing.
|
|
22
|
+
*/
|
|
23
|
+
export declare function applyContextOverride(appConfig: AppConfig, modelId: string, contextLength: number | null): AppConfig;
|
|
24
|
+
/** Human-readable description of where artifacts come from and how they are cached. */
|
|
25
|
+
export declare function modelSourceDescription(mode: ModelSourceMode, cacheBackend: BrowserCacheBackend): string;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=model-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-source.d.ts","sourceRoot":"","s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AmB,GAAG,MAAM,CAQvG"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { applyCuratedModelRecordOverrides, CUSTOM_MODEL_RECORDS } from "./models.js";
|
|
2
|
+
const HUGGING_FACE_HOST = "huggingface.co";
|
|
3
|
+
const RAW_GITHUB_HOST = "raw.githubusercontent.com";
|
|
4
|
+
/** The Cache API bucket Transformers.js artifacts are cached in (shared with model-cache cleanup). */
|
|
5
|
+
export const TRANSFORMERS_CACHE_KEY = "transformers-cache";
|
|
6
|
+
/**
|
|
7
|
+
* Build the WebLLM AppConfig for a load: the bundled prebuilt records merged with the SDK's custom
|
|
8
|
+
* MLC records and curated overrides, optionally rewritten to same-origin proxy routes, with the
|
|
9
|
+
* chosen artifact cache backend applied. `proxyOrigin` is only read in proxy mode.
|
|
10
|
+
*/
|
|
11
|
+
export function buildWebLLMAppConfig(webllm, mode, proxyOrigin, cacheBackend) {
|
|
12
|
+
const mergedConfig = withCustomModelRecords(webllm.prebuiltAppConfig);
|
|
13
|
+
const baseConfig = mode === "direct" ? mergedConfig : buildProxiedAppConfig(mergedConfig, proxyOrigin);
|
|
14
|
+
return {
|
|
15
|
+
...baseConfig,
|
|
16
|
+
cacheBackend,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function withCustomModelRecords(appConfig) {
|
|
20
|
+
const existingModelIds = new Set(appConfig.model_list.map((record) => record.model_id));
|
|
21
|
+
const missingCustomRecords = CUSTOM_MODEL_RECORDS.filter((record) => !existingModelIds.has(record.model_id));
|
|
22
|
+
const modelList = [...appConfig.model_list, ...missingCustomRecords].map(applyCuratedModelRecordOverrides);
|
|
23
|
+
return {
|
|
24
|
+
...appConfig,
|
|
25
|
+
model_list: modelList,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function buildProxiedAppConfig(appConfig, origin) {
|
|
29
|
+
const modelList = appConfig.model_list.map((record) => proxyModelRecord(record, origin));
|
|
30
|
+
return {
|
|
31
|
+
...appConfig,
|
|
32
|
+
model_list: modelList,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function proxyModelRecord(record, origin) {
|
|
36
|
+
return {
|
|
37
|
+
...record,
|
|
38
|
+
model: proxyHuggingFaceUrl(record.model, origin),
|
|
39
|
+
// WebLLM's bundled model_lib values usually point at raw.githubusercontent.com, while custom
|
|
40
|
+
// MLC builds may point at Hugging Face. Proxy both forms so hosted Worker deployments stay
|
|
41
|
+
// same-origin and avoid CORS/cache differences.
|
|
42
|
+
model_lib: proxyModelLibraryUrl(record.model_lib, origin),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function proxyModelLibraryUrl(rawUrl, origin) {
|
|
46
|
+
return proxyRawGithubUrl(proxyHuggingFaceUrl(rawUrl, origin), origin);
|
|
47
|
+
}
|
|
48
|
+
export function proxyHuggingFaceUrl(rawUrl, origin) {
|
|
49
|
+
let modelUrl;
|
|
50
|
+
try {
|
|
51
|
+
modelUrl = new URL(rawUrl);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return rawUrl;
|
|
55
|
+
}
|
|
56
|
+
if (modelUrl.hostname !== HUGGING_FACE_HOST) {
|
|
57
|
+
return rawUrl;
|
|
58
|
+
}
|
|
59
|
+
const parts = modelUrl.pathname.split("/").filter(Boolean);
|
|
60
|
+
const [owner, repo, ...suffixParts] = parts;
|
|
61
|
+
if (!owner || !repo) {
|
|
62
|
+
return rawUrl;
|
|
63
|
+
}
|
|
64
|
+
const proxiedPath = ["hf", owner, repo, ...suffixParts].map(encodeURIComponent).join("/");
|
|
65
|
+
const proxied = new URL(`/${proxiedPath}`, origin);
|
|
66
|
+
proxied.search = modelUrl.search;
|
|
67
|
+
return proxied.href;
|
|
68
|
+
}
|
|
69
|
+
export function proxyRawGithubUrl(rawUrl, origin) {
|
|
70
|
+
let modelLibUrl;
|
|
71
|
+
try {
|
|
72
|
+
modelLibUrl = new URL(rawUrl);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return rawUrl;
|
|
76
|
+
}
|
|
77
|
+
if (modelLibUrl.hostname !== RAW_GITHUB_HOST) {
|
|
78
|
+
return rawUrl;
|
|
79
|
+
}
|
|
80
|
+
const parts = modelLibUrl.pathname.split("/").filter(Boolean);
|
|
81
|
+
const [owner, repo, branch, ...fileParts] = parts;
|
|
82
|
+
if (!owner || !repo || !branch || fileParts.length === 0) {
|
|
83
|
+
return rawUrl;
|
|
84
|
+
}
|
|
85
|
+
const proxiedPath = ["gh-raw", owner, repo, branch, ...fileParts].map(encodeURIComponent).join("/");
|
|
86
|
+
const proxied = new URL(`/${proxiedPath}`, origin);
|
|
87
|
+
proxied.search = modelLibUrl.search;
|
|
88
|
+
return proxied.href;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Merge a caller-supplied context length into the selected model's record overrides. Preserves any
|
|
92
|
+
* curated overrides (e.g. Gemma's fixed sliding-window config) by merging rather than replacing.
|
|
93
|
+
*/
|
|
94
|
+
export function applyContextOverride(appConfig, modelId, contextLength) {
|
|
95
|
+
if (contextLength === null)
|
|
96
|
+
return appConfig;
|
|
97
|
+
return {
|
|
98
|
+
...appConfig,
|
|
99
|
+
model_list: appConfig.model_list.map((record) => record.model_id === modelId ? { ...record, overrides: { ...(record.overrides ?? {}), context_window_size: contextLength } } : record),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Human-readable description of where artifacts come from and how they are cached. */
|
|
103
|
+
export function modelSourceDescription(mode, cacheBackend) {
|
|
104
|
+
const cacheText = cacheBackend === "indexeddb" ? "browser IndexedDB" : `the browser ${cacheBackend} backend`;
|
|
105
|
+
if (mode === "same-origin-proxy") {
|
|
106
|
+
return `Model files are fetched through the proxy Worker at /hf/* and WebLLM libraries through /gh-raw/*, then cached in ${cacheText}.`;
|
|
107
|
+
}
|
|
108
|
+
return `Model files are fetched directly from Hugging Face and cached in ${cacheText}.`;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=model-source.js.map
|
|
@@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WAAW,EAAE,EAAE,MAAM,CAAC,CAAC;IACnD,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAEpC,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAoB,EAAE,OAAe,EAAE,aAA4B;IACtG,IAAI,aAAa,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO;QACL,GAAG,SAAS;QACZ,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAC9C,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,mBAAmB,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACrI;KACF,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,sBAAsB,CAAC,IAAqB,EAAE,YAAiC;IAC7F,MAAM,SAAS,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,eAAe,YAAY,UAAU,CAAC;IAE7G,IAAI,IAAI,KAAK,mBAAmB,EAAE,CAAC;QACjC,OAAO,oHAAoH,SAAS,GAAG,CAAC;IAC1I,CAAC;IAED,OAAO,oEAAoE,SAAS,GAAG,CAAC;AAC1F,CAAC"}
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ModelRecord } from "@mlc-ai/web-llm";
|
|
2
|
+
export type RuntimePreset = {
|
|
3
|
+
maxTokens: number;
|
|
4
|
+
temperature: number;
|
|
5
|
+
topP: number;
|
|
6
|
+
repetitionPenalty: number;
|
|
7
|
+
frequencyPenalty: number;
|
|
8
|
+
presencePenalty: number;
|
|
9
|
+
seed: number | null;
|
|
10
|
+
disableThinking: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type ModelBackend = "webllm" | "transformers-js";
|
|
13
|
+
/** Input/output modality of a model, used for the library modality-flow line + Playground gating. */
|
|
14
|
+
export type Modality = "text" | "image" | "audio";
|
|
15
|
+
/** Capability task keys. Map to the TYPE chips: text→LLM, vision→VLM, stt→STT, tts→TTS. */
|
|
16
|
+
export type ModelTask = "text" | "vision" | "stt" | "tts";
|
|
17
|
+
/**
|
|
18
|
+
* How a non-LLM-text model loads + runs in the browser. Undefined means a plain text LLM that uses
|
|
19
|
+
* the existing WebLLM / Transformers.js text-generation path. Each variant maps to a verified
|
|
20
|
+
* inference recipe in llm/multimodal.ts.
|
|
21
|
+
*/
|
|
22
|
+
export type MultimodalRuntime = "stt" | "tts-kokoro" | "tts-pipeline" | "vlm-vision2seq" | "vlm-imagetext" | "audio-text-to-text" | "voxtral-realtime" | "gemma-mm";
|
|
23
|
+
export type ModelPreset = {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
shortName: string;
|
|
27
|
+
description: string;
|
|
28
|
+
approximateDownload: string;
|
|
29
|
+
vramRequiredMB: number;
|
|
30
|
+
/** "estimated" means the value is not from WebLLM's bundled prebuilt metadata. */
|
|
31
|
+
vramSource: "webllm" | "estimated";
|
|
32
|
+
lowResourceRequired: boolean;
|
|
33
|
+
disableThinkingSupported: boolean;
|
|
34
|
+
defaultRuntime: RuntimePreset;
|
|
35
|
+
source: "webllm-prebuilt" | "custom-mlc" | "transformers-onnx";
|
|
36
|
+
backend: ModelBackend;
|
|
37
|
+
stability: "recommended" | "stable" | "experimental";
|
|
38
|
+
officialRepo: string;
|
|
39
|
+
artifactRepo?: string;
|
|
40
|
+
notes?: string;
|
|
41
|
+
/** Optional dtype passed to Transformers.js, e.g. q4 or q4f16. */
|
|
42
|
+
transformersDtype?: string;
|
|
43
|
+
/** Capability tasks (TYPE chips + Playground tab gating). Defaults to ["text"] (a plain LLM). */
|
|
44
|
+
tasks?: ModelTask[];
|
|
45
|
+
/** Input modalities for the library modality-flow line. Defaults to ["text"]. */
|
|
46
|
+
modalityIn?: Modality[];
|
|
47
|
+
/** Output modalities. Defaults to ["text"]. */
|
|
48
|
+
modalityOut?: Modality[];
|
|
49
|
+
/** How a multimodal (non-LLM-text) model loads + runs. Undefined for plain text LLMs. */
|
|
50
|
+
mmRuntime?: MultimodalRuntime;
|
|
51
|
+
/** Optional display brand for the vendor tag (e.g. "Moonshine", "Kokoro", "Zhipu"). Falls back to the vendor label. */
|
|
52
|
+
brand?: string;
|
|
53
|
+
};
|
|
54
|
+
/** Friendly capability names surfaced across the app (type chips/filters, setup dropdown/filters). */
|
|
55
|
+
export declare const TASK_LABELS: Record<ModelTask, string>;
|
|
56
|
+
export declare const TASK_ICONS: Record<ModelTask, string>;
|
|
57
|
+
export declare const MODALITY_LABELS: Record<Modality, string>;
|
|
58
|
+
export declare const MODALITY_ICONS: Record<Modality, string>;
|
|
59
|
+
/** Task capabilities for a preset, defaulting a bare LLM to ["text"]. */
|
|
60
|
+
export declare function presetTasks(preset: ModelPreset): ModelTask[];
|
|
61
|
+
/** Canonical ordering of the four capability slots (Text / Image / Transcription / Speech). */
|
|
62
|
+
export declare const SLOT_ORDER: ModelTask[];
|
|
63
|
+
/**
|
|
64
|
+
* The capability SLOTS a model occupies when loaded — one per its {@link presetTasks}. Used to bound
|
|
65
|
+
* concurrent loads to one model per slot (Text/Image/Transcription/Speech).
|
|
66
|
+
*
|
|
67
|
+
* NOTE: image-text-to-text VLMs (SmolVLM/Qwen3-VL/GLM-OCR) do NOT fill the Text slot — their
|
|
68
|
+
* Transformers.js processors require an image and error ("No images provided") on text-only input, so
|
|
69
|
+
* they cannot drive the text tabs. Only genuine text runtimes (LLMs, and Gemma-4 multimodal which has
|
|
70
|
+
* a verified text path) fill Text. A VLM therefore occupies just the Image slot.
|
|
71
|
+
*/
|
|
72
|
+
export declare function modelSlots(preset: ModelPreset): ModelTask[];
|
|
73
|
+
export declare function presetModalityIn(preset: ModelPreset): Modality[];
|
|
74
|
+
export declare function presetModalityOut(preset: ModelPreset): Modality[];
|
|
75
|
+
/** A selectable TTS speaker voice (id → display name + short tag). */
|
|
76
|
+
export type TtsVoice = {
|
|
77
|
+
id: string;
|
|
78
|
+
label: string;
|
|
79
|
+
tag: string;
|
|
80
|
+
};
|
|
81
|
+
/** Model ids of the TTS presets, used to look up their voice rosters. */
|
|
82
|
+
export declare const KOKORO_MODEL_ID = "onnx-community/Kokoro-82M-v1.0-ONNX";
|
|
83
|
+
export declare const SUPERTONIC_MODEL_ID = "onnx-community/Supertonic-TTS-ONNX";
|
|
84
|
+
export declare const SUPERTONIC_2_MODEL_ID = "onnx-community/Supertonic-TTS-2-ONNX";
|
|
85
|
+
/** Kokoro voice roster surfaced in the TTS tab (id → display name + tag), verified voice ids. */
|
|
86
|
+
export declare const KOKORO_VOICES: TtsVoice[];
|
|
87
|
+
/**
|
|
88
|
+
* Supertonic speaker roster. The repo ships ten speaker-embedding files under `voices/` — F1–F5
|
|
89
|
+
* (female) and M1–M5 (male) — verified against the Hugging Face repo file tree. The voice id is the
|
|
90
|
+
* `.bin` basename consumed as the pipeline's `speaker_embeddings`.
|
|
91
|
+
*/
|
|
92
|
+
export declare const SUPERTONIC_VOICES: TtsVoice[];
|
|
93
|
+
/** The selectable voices for a TTS model (empty for non-TTS models). */
|
|
94
|
+
export declare function ttsVoicesForModel(modelId: string): TtsVoice[];
|
|
95
|
+
export declare const MODEL_RECORD_OVERRIDES: Record<string, NonNullable<ModelRecord["overrides"]>>;
|
|
96
|
+
export declare function applyCuratedModelRecordOverrides(record: ModelRecord): ModelRecord;
|
|
97
|
+
export declare const CUSTOM_MODEL_RECORDS: ModelRecord[];
|
|
98
|
+
export declare const CUSTOM_MODEL_RECORD_IDS: Set<string>;
|
|
99
|
+
export declare const MODEL_PRESETS: ModelPreset[];
|
|
100
|
+
export declare function getModelPreset(modelId: string): ModelPreset;
|
|
101
|
+
export declare function formatMB(mb: number): string;
|
|
102
|
+
export declare function modelRepoLabel(preset: ModelPreset): string;
|
|
103
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAExD,qGAAqG;AACrG,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAClD,2FAA2F;AAC3F,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;AAC1D;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB,KAAK,GACL,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,oBAAoB,GACpB,kBAAkB,GAClB,UAAU,CAAC;AAEf,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,kFAAkF;IAClF,UAAU,EAAE,QAAQ,GAAG,WAAW,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,wBA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