webslm 0.4.1 → 0.6.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/README.md +35 -5
- package/dist/ai-sdk/language-model.d.ts +4 -1
- package/dist/ai-sdk/language-model.js +6 -3
- package/dist/ai-sdk/prompt.d.ts +5 -3
- package/dist/ai-sdk/prompt.js +57 -5
- package/dist/cache/models.d.ts +4 -3
- package/dist/cache/models.js +25 -12
- package/dist/client.d.ts +1 -2
- package/dist/curated.js +9 -0
- package/dist/download.d.ts +5 -0
- package/dist/download.js +11 -6
- package/dist/engine.js +50 -14
- package/dist/fit.d.ts +1 -1
- package/dist/fit.js +2 -1
- package/dist/hub.d.ts +22 -2
- package/dist/hub.js +60 -5
- package/dist/index.d.ts +1 -1
- package/dist/media.d.ts +72 -0
- package/dist/media.js +358 -0
- package/dist/memory.d.ts +5 -0
- package/dist/memory.js +47 -6
- package/dist/models.d.ts +13 -4
- package/dist/models.js +112 -20
- package/dist/native.d.ts +3 -0
- package/dist/protocol.d.ts +32 -1
- package/dist/recommended-sampling.js +6 -1
- package/dist/simple.d.ts +11 -2
- package/dist/simple.js +17 -8
- package/dist/types.d.ts +109 -2
- package/native-manifest.json +29 -29
- package/package.json +1 -1
- package/wasm/relaxed/webslm_wasm.d.ts +29 -4
- package/wasm/relaxed/webslm_wasm.js +75 -16
- package/wasm/relaxed/webslm_wasm_bg.wasm +0 -0
- package/wasm/relaxed/webslm_wasm_bg.wasm.d.ts +5 -3
- package/wasm/simd/webslm_wasm.d.ts +29 -4
- package/wasm/simd/webslm_wasm.js +75 -16
- package/wasm/simd/webslm_wasm_bg.wasm +0 -0
- package/wasm/simd/webslm_wasm_bg.wasm.d.ts +5 -3
- package/wasm/threads/webslm_wasm.d.ts +30 -5
- package/wasm/threads/webslm_wasm.js +80 -21
- package/wasm/threads/webslm_wasm_bg.wasm +0 -0
- package/wasm/threads/webslm_wasm_bg.wasm.d.ts +6 -4
package/dist/types.d.ts
CHANGED
|
@@ -52,21 +52,33 @@ export type FileData = Blob | ArrayBuffer | Uint8Array;
|
|
|
52
52
|
* optional files such as `generation_config.json` are probed this way.
|
|
53
53
|
*/
|
|
54
54
|
export type FetchFile = (path: string, range?: readonly [number, number]) => Promise<ArrayBuffer | Uint8Array | null | undefined>;
|
|
55
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Where a checkpoint comes from. A plain string is a Hugging Face repository id.
|
|
57
|
+
*
|
|
58
|
+
* `file` names a GGUF file of the source to load instead of safetensors
|
|
59
|
+
* weights (e.g. `"SmolLM2-135M-Instruct-Q8_0.gguf"`): its metadata gives
|
|
60
|
+
* the configuration, the tokenizer (unless a `tokenizer.json` sits next to
|
|
61
|
+
* it) and the chat template. A hub repository or a `files` source holding
|
|
62
|
+
* GGUF files and no safetensors loads its preferred GGUF file (Q8_0, else
|
|
63
|
+
* Q4_K_M, Q4_0...) without it; a `fetch` source needs it.
|
|
64
|
+
*/
|
|
56
65
|
export type ModelSource =
|
|
57
66
|
/** A Hugging Face repository, downloaded once into the local cache. */
|
|
58
67
|
{
|
|
59
68
|
readonly hub: string;
|
|
60
69
|
readonly revision?: string;
|
|
61
70
|
readonly hubUrl?: string;
|
|
71
|
+
readonly file?: string;
|
|
62
72
|
}
|
|
63
|
-
/** Files by name: `"config.json"`, `"tokenizer.json"`, `"model.safetensors"`... */
|
|
73
|
+
/** Files by name: `"config.json"`, `"tokenizer.json"`, `"model.safetensors"`, `"model.gguf"`... */
|
|
64
74
|
| {
|
|
65
75
|
readonly files: Readonly<Record<string, FileData>>;
|
|
76
|
+
readonly file?: string;
|
|
66
77
|
}
|
|
67
78
|
/** A custom store. */
|
|
68
79
|
| {
|
|
69
80
|
readonly fetch: FetchFile;
|
|
81
|
+
readonly file?: string;
|
|
70
82
|
};
|
|
71
83
|
/**
|
|
72
84
|
* A PEFT LoRA adapter: a Hugging Face repository id (a string or
|
|
@@ -213,6 +225,12 @@ export interface LoadModelOptions {
|
|
|
213
225
|
* same logits, whatever the browser, CPU or thread count.
|
|
214
226
|
*/
|
|
215
227
|
readonly deterministic?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* `false` loads a vision-language checkpoint without its vision encoder,
|
|
230
|
+
* as a text-only model, to save its memory (Qwen3.5-0.8B's encoder has
|
|
231
|
+
* 100M parameters). Default `true`.
|
|
232
|
+
*/
|
|
233
|
+
readonly vision?: boolean;
|
|
216
234
|
/**
|
|
217
235
|
* WebAssembly build to run (advanced; defaults to the fastest one the
|
|
218
236
|
* environment supports: `"threads"` when the page is cross-origin
|
|
@@ -250,7 +268,86 @@ export interface CpuInfo {
|
|
|
250
268
|
}
|
|
251
269
|
export interface ChatMessage {
|
|
252
270
|
readonly role: "system" | "user" | "assistant" | (string & {});
|
|
271
|
+
/** The text of the message. */
|
|
253
272
|
readonly content: string;
|
|
273
|
+
/**
|
|
274
|
+
* Images and videos sent with the message, placed before its text
|
|
275
|
+
* (vision-language models, see `ModelInfo.vision`).
|
|
276
|
+
*/
|
|
277
|
+
readonly media?: readonly MediaPart[];
|
|
278
|
+
}
|
|
279
|
+
/** An image or a video of a message. */
|
|
280
|
+
export type MediaPart = {
|
|
281
|
+
readonly type: "image";
|
|
282
|
+
readonly image: ImageInput;
|
|
283
|
+
} | {
|
|
284
|
+
readonly type: "video";
|
|
285
|
+
readonly video: VideoInput;
|
|
286
|
+
};
|
|
287
|
+
/** One part of a {@link MultimodalMessage}. */
|
|
288
|
+
export type ContentPart = {
|
|
289
|
+
readonly type: "text";
|
|
290
|
+
readonly text: string;
|
|
291
|
+
} | MediaPart;
|
|
292
|
+
/**
|
|
293
|
+
* A message whose content interleaves text, images and videos in any
|
|
294
|
+
* order, as `Model.chat`, `Session.chat` and `generate` also take.
|
|
295
|
+
*/
|
|
296
|
+
export interface MultimodalMessage {
|
|
297
|
+
readonly role: "system" | "user" | "assistant" | (string & {});
|
|
298
|
+
readonly content: readonly ContentPart[];
|
|
299
|
+
}
|
|
300
|
+
/** What the chat methods take: a {@link ChatMessage} or a {@link MultimodalMessage}. */
|
|
301
|
+
export type ChatInputMessage = ChatMessage | MultimodalMessage;
|
|
302
|
+
/**
|
|
303
|
+
* Decoded RGBA pixels, row by row (`channels`: 4 by default; 3 for RGB, 1
|
|
304
|
+
* for gray).
|
|
305
|
+
*/
|
|
306
|
+
export interface RawImage {
|
|
307
|
+
readonly data: Uint8Array | Uint8ClampedArray;
|
|
308
|
+
readonly width: number;
|
|
309
|
+
readonly height: number;
|
|
310
|
+
readonly channels?: 1 | 3 | 4;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* An image: a URL (`https:`, `data:`, `blob:`), the bytes of a PNG, JPEG,
|
|
314
|
+
* WebP or GIF file, a `Blob`, an `ImageBitmap`, `ImageData`, an image,
|
|
315
|
+
* canvas or video element (its current frame), or decoded pixels. In Node,
|
|
316
|
+
* image files are decoded by the native engine; the WebAssembly engine
|
|
317
|
+
* takes pixels there.
|
|
318
|
+
*/
|
|
319
|
+
export type ImageInput = string | URL | Uint8Array | ArrayBuffer | Blob | ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | RawImage;
|
|
320
|
+
/** Frames of a video, already sampled. */
|
|
321
|
+
export interface VideoFrames {
|
|
322
|
+
readonly frames: readonly ImageInput[];
|
|
323
|
+
/** Frames per second of `frames` (the timestamps are `i / fps`). */
|
|
324
|
+
readonly fps?: number;
|
|
325
|
+
/** Time of each frame in seconds (in place of `fps`). */
|
|
326
|
+
readonly timestamps?: readonly number[];
|
|
327
|
+
/** Length of the whole video in seconds. */
|
|
328
|
+
readonly duration?: number;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* A video: a `<video>` element, a URL or a `Blob` (sampled in the browser
|
|
332
|
+
* by seeking a `<video>` element, see {@link MediaOptions}), or frames.
|
|
333
|
+
*/
|
|
334
|
+
export type VideoInput = HTMLVideoElement | string | URL | Blob | VideoFrames;
|
|
335
|
+
/** How the images and videos of a conversation are read. */
|
|
336
|
+
export interface MediaOptions {
|
|
337
|
+
/** Most frames sampled from a video (default 32). */
|
|
338
|
+
readonly maxFrames?: number;
|
|
339
|
+
/** Frames sampled per second of video (default 2; the model's processor may keep fewer). */
|
|
340
|
+
readonly fps?: number;
|
|
341
|
+
/**
|
|
342
|
+
* Longest image side the processor scales images to, in place of the
|
|
343
|
+
* checkpoint's (SmolVLM): smaller values give fewer tiles and tokens.
|
|
344
|
+
*/
|
|
345
|
+
readonly longestEdge?: number;
|
|
346
|
+
/**
|
|
347
|
+
* Processor settings replacing the checkpoint's (`preprocessor_config.json`
|
|
348
|
+
* keys, e.g. `{ max_image_tokens: 64 }` for LFM2-VL).
|
|
349
|
+
*/
|
|
350
|
+
readonly processor?: Readonly<Record<string, unknown>>;
|
|
254
351
|
}
|
|
255
352
|
/**
|
|
256
353
|
* Options of a generation. Unset sampling options come from the model card's
|
|
@@ -317,6 +414,8 @@ export interface GenerateOptions {
|
|
|
317
414
|
readonly contextShift?: boolean | {
|
|
318
415
|
readonly keep?: number;
|
|
319
416
|
};
|
|
417
|
+
/** How the images and videos of the messages are read (vision-language models). */
|
|
418
|
+
readonly media?: MediaOptions;
|
|
320
419
|
/**
|
|
321
420
|
* Called with every generated token. Returning `false` stops the
|
|
322
421
|
* generation right there (`finishReason: "aborted"`): the output ends
|
|
@@ -490,6 +589,14 @@ export interface ModelInfo {
|
|
|
490
589
|
readonly tiesEmbeddings: boolean;
|
|
491
590
|
readonly hasRecurrentState: boolean;
|
|
492
591
|
readonly hasChatTemplate: boolean;
|
|
592
|
+
/**
|
|
593
|
+
* What a vision-language model takes besides text: images, and videos
|
|
594
|
+
* when its processor samples them (absent for text models).
|
|
595
|
+
*/
|
|
596
|
+
readonly vision?: {
|
|
597
|
+
readonly images: boolean;
|
|
598
|
+
readonly videos: boolean;
|
|
599
|
+
};
|
|
493
600
|
readonly stopTokens: readonly number[];
|
|
494
601
|
readonly tokenizer: {
|
|
495
602
|
readonly vocabSize: number;
|
package/native-manifest.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.6.0",
|
|
3
3
|
"assets": {
|
|
4
4
|
"darwin-arm64": {
|
|
5
|
-
"file": "webslm-node-0.
|
|
6
|
-
"size":
|
|
7
|
-
"sha256": "
|
|
8
|
-
"nodeSha256": "
|
|
5
|
+
"file": "webslm-node-0.6.0-darwin-arm64.node.gz",
|
|
6
|
+
"size": 5143165,
|
|
7
|
+
"sha256": "f2700ee1eb7d60ccd0c50053cf67e15d34c6056413f22b4fd69e73ed8ef45783",
|
|
8
|
+
"nodeSha256": "66bfdd8160ddb128beb6055f42161e0c47d21f82772035cdd09e58db6f6fd502"
|
|
9
9
|
},
|
|
10
10
|
"darwin-x64": {
|
|
11
|
-
"file": "webslm-node-0.
|
|
12
|
-
"size":
|
|
13
|
-
"sha256": "
|
|
14
|
-
"nodeSha256": "
|
|
11
|
+
"file": "webslm-node-0.6.0-darwin-x64.node.gz",
|
|
12
|
+
"size": 5416993,
|
|
13
|
+
"sha256": "4390851cb0bf1698b0308b7932dee58a10bd6cdb0390333fefc8e316fb7f9601",
|
|
14
|
+
"nodeSha256": "5f9cfd9c62d275415a04c6f3fb12c9fa7435e538a8952cef80d4992e4b52d31f"
|
|
15
15
|
},
|
|
16
16
|
"linux-x64-gnu": {
|
|
17
|
-
"file": "webslm-node-0.
|
|
18
|
-
"size":
|
|
19
|
-
"sha256": "
|
|
20
|
-
"nodeSha256": "
|
|
17
|
+
"file": "webslm-node-0.6.0-linux-x64-gnu.node.gz",
|
|
18
|
+
"size": 5453454,
|
|
19
|
+
"sha256": "66b4efe9cd4b944addd326c0d927abada2e78f96425e4976aa230756aca75d88",
|
|
20
|
+
"nodeSha256": "8d77ea1816275d4516253f49cd94720a2c722f9f2e9ce218efb437c32ebe6acd"
|
|
21
21
|
},
|
|
22
22
|
"linux-arm64-gnu": {
|
|
23
|
-
"file": "webslm-node-0.
|
|
24
|
-
"size":
|
|
25
|
-
"sha256": "
|
|
26
|
-
"nodeSha256": "
|
|
23
|
+
"file": "webslm-node-0.6.0-linux-arm64-gnu.node.gz",
|
|
24
|
+
"size": 5121058,
|
|
25
|
+
"sha256": "84bf11007c312761dc2377de89725bd839cb538834c01f80b26e1b0ba9456d7a",
|
|
26
|
+
"nodeSha256": "4596e8f5180ed2e1cb20721ac01142f4a1fa8e062a86280053acf377159d8ba2"
|
|
27
27
|
},
|
|
28
28
|
"linux-x64-musl": {
|
|
29
|
-
"file": "webslm-node-0.
|
|
30
|
-
"size":
|
|
31
|
-
"sha256": "
|
|
32
|
-
"nodeSha256": "
|
|
29
|
+
"file": "webslm-node-0.6.0-linux-x64-musl.node.gz",
|
|
30
|
+
"size": 5842409,
|
|
31
|
+
"sha256": "9a8ddc2a0f0649714ae8cbca9e31fa2405fdaf628ac14ec97296877c37e4506f",
|
|
32
|
+
"nodeSha256": "25f73331e30d7e2e2295af07fcbc7f0d747f5ef80803da2830fd175f61e670b1"
|
|
33
33
|
},
|
|
34
34
|
"linux-arm64-musl": {
|
|
35
|
-
"file": "webslm-node-0.
|
|
36
|
-
"size":
|
|
37
|
-
"sha256": "
|
|
38
|
-
"nodeSha256": "
|
|
35
|
+
"file": "webslm-node-0.6.0-linux-arm64-musl.node.gz",
|
|
36
|
+
"size": 5627078,
|
|
37
|
+
"sha256": "44178e33156cb2b6321414f74d4d4f9944183b2a2625cd5be19d21e16fd6dc21",
|
|
38
|
+
"nodeSha256": "3d76dacae55375d839b3d731634704fed52a84429288c2c9878be017d9a5ac78"
|
|
39
39
|
},
|
|
40
40
|
"win32-x64-msvc": {
|
|
41
|
-
"file": "webslm-node-0.
|
|
42
|
-
"size":
|
|
43
|
-
"sha256": "
|
|
44
|
-
"nodeSha256": "
|
|
41
|
+
"file": "webslm-node-0.6.0-win32-x64-msvc.node.gz",
|
|
42
|
+
"size": 5886895,
|
|
43
|
+
"sha256": "9c96790b22159549d6e620460311aa243bee8c217d8ff0d536f29e4381792c2d",
|
|
44
|
+
"nodeSha256": "911cfe54c80b1e4f8476c3778981e73dc774e34cc1108ed848fbe93240e16e8d"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webslm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Run small language models in the browser and in Node, straight from their original Hugging Face checkpoints: a Rust engine compiled to WebAssembly, in a worker, with an offline cache.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Maxime Golfier",
|
|
@@ -66,6 +66,11 @@ export class WasmModel {
|
|
|
66
66
|
* model. Sessions start over at their next call.
|
|
67
67
|
*/
|
|
68
68
|
applyAdapter(lora: JsSource, options_json: string): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Answers a conversation with images or videos in the default
|
|
71
|
+
* session; see [`WasmSession::chat_with_media`].
|
|
72
|
+
*/
|
|
73
|
+
chatWithMedia(messages_json: string, options_json: string, media_json: string, media_data: Uint8Array, on_delta: Function, on_prefill?: Function | null): Promise<any>;
|
|
69
74
|
/**
|
|
70
75
|
* Answers a conversation in the default session; see
|
|
71
76
|
* [`WasmSession::chat`].
|
|
@@ -93,7 +98,9 @@ export class WasmModel {
|
|
|
93
98
|
* `{ format?: "q8" | "q4" | "q4_0" | "f32" | "f16" | "bf16",
|
|
94
99
|
* contextLength?: number, deterministic?: boolean,
|
|
95
100
|
* activations?: "quantized" | "f32", device?: "cpu" | "webgpu" | "auto",
|
|
96
|
-
* adapterScale?: number, adapterMode?: "unmerged" | "merged"
|
|
101
|
+
* adapterScale?: number, adapterMode?: "unmerged" | "merged",
|
|
102
|
+
* vision?: boolean }` (`vision: false` skips the vision encoder of a
|
|
103
|
+
* vision-language checkpoint).
|
|
97
104
|
*
|
|
98
105
|
* `device` defaults to `"cpu"`. `"auto"` picks WebGPU when an adapter
|
|
99
106
|
* is available and the model has more than
|
|
@@ -112,6 +119,12 @@ export class WasmModel {
|
|
|
112
119
|
* weights: a valid stored file serves them instead of converting the
|
|
113
120
|
* checkpoint, else they are written to it as they are converted;
|
|
114
121
|
* `info().weightCache` says which (see [`WeightCacheOutcome`]).
|
|
122
|
+
*
|
|
123
|
+
* `ggufFile` loads that GGUF file of the source (a source listing
|
|
124
|
+
* GGUF files and no safetensors loads its preferred one). Without
|
|
125
|
+
* `format`, a pre-quantized checkpoint (a `Q8_0` GGUF file, a
|
|
126
|
+
* `webslm export` checkpoint) loads in its own format, its blocks
|
|
127
|
+
* unchanged; weights already in the load format skip `weightCache`.
|
|
115
128
|
*/
|
|
116
129
|
static load(source: JsSource, options_json: string, lora?: JsSource | null, weight_cache?: JsWeightCache | null): Promise<WasmModel>;
|
|
117
130
|
/**
|
|
@@ -144,6 +157,16 @@ export class WasmSession {
|
|
|
144
157
|
private constructor();
|
|
145
158
|
free(): void;
|
|
146
159
|
[Symbol.dispose](): void;
|
|
160
|
+
/**
|
|
161
|
+
* Answers a conversation whose messages hold image or video parts
|
|
162
|
+
* (`{"type": "image"}`, `{"type": "video"}`), with a vision-language
|
|
163
|
+
* model. `media_json` describes the images and videos, one per part in
|
|
164
|
+
* order, and `media_data` holds their RGBA pixels back to back (see
|
|
165
|
+
* `webslm_bindings::media`); the `media` generation option sets the
|
|
166
|
+
* video sampling (`maxFrames`, `fps`) and processor settings. Same
|
|
167
|
+
* callbacks and result as [`WasmSession::chat`].
|
|
168
|
+
*/
|
|
169
|
+
chatWithMedia(messages_json: string, options_json: string, media_json: string, media_data: Uint8Array, on_delta: Function, on_prefill?: Function | null): Promise<any>;
|
|
147
170
|
/**
|
|
148
171
|
* Answers a conversation: `messages_json` is a JSON array of
|
|
149
172
|
* `{ role, content }`, `options_json` a JSON object of generation
|
|
@@ -286,6 +309,7 @@ export interface InitOutput {
|
|
|
286
309
|
readonly version: () => [number, number];
|
|
287
310
|
readonly wasmmodel_applyAdapter: (a: number, b: number, c: number, d: number) => any;
|
|
288
311
|
readonly wasmmodel_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
312
|
+
readonly wasmmodel_chatWithMedia: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any, k: number) => any;
|
|
289
313
|
readonly wasmmodel_createSession: (a: number) => [number, number, number];
|
|
290
314
|
readonly wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
291
315
|
readonly wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
@@ -297,6 +321,7 @@ export interface InitOutput {
|
|
|
297
321
|
readonly wasmmodel_tokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
298
322
|
readonly wasmsession_capacity: (a: number) => [number, number, number];
|
|
299
323
|
readonly wasmsession_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
324
|
+
readonly wasmsession_chatWithMedia: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any, k: number) => any;
|
|
300
325
|
readonly wasmsession_computed: (a: number) => [number, number, number];
|
|
301
326
|
readonly wasmsession_fork: (a: number) => [number, number, number];
|
|
302
327
|
readonly wasmsession_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
@@ -311,10 +336,10 @@ export interface InitOutput {
|
|
|
311
336
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
312
337
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
313
338
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
314
|
-
readonly
|
|
315
|
-
readonly
|
|
339
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__40: (a: number, b: number, c: any) => [number, number];
|
|
340
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__41: (a: number, b: number, c: any) => [number, number];
|
|
316
341
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
317
|
-
readonly
|
|
342
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__39: (a: number, b: number, c: any) => void;
|
|
318
343
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
319
344
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
320
345
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -157,6 +157,29 @@ export class WasmModel {
|
|
|
157
157
|
const ret = wasm.wasmmodel_applyAdapter(this.__wbg_ptr, ptr0, ptr1, len1);
|
|
158
158
|
return ret;
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Answers a conversation with images or videos in the default
|
|
162
|
+
* session; see [`WasmSession::chat_with_media`].
|
|
163
|
+
* @param {string} messages_json
|
|
164
|
+
* @param {string} options_json
|
|
165
|
+
* @param {string} media_json
|
|
166
|
+
* @param {Uint8Array} media_data
|
|
167
|
+
* @param {Function} on_delta
|
|
168
|
+
* @param {Function | null} [on_prefill]
|
|
169
|
+
* @returns {Promise<any>}
|
|
170
|
+
*/
|
|
171
|
+
chatWithMedia(messages_json, options_json, media_json, media_data, on_delta, on_prefill) {
|
|
172
|
+
const ptr0 = passStringToWasm0(messages_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
173
|
+
const len0 = WASM_VECTOR_LEN;
|
|
174
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
175
|
+
const len1 = WASM_VECTOR_LEN;
|
|
176
|
+
const ptr2 = passStringToWasm0(media_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
177
|
+
const len2 = WASM_VECTOR_LEN;
|
|
178
|
+
const ptr3 = passArray8ToWasm0(media_data, wasm.__wbindgen_malloc);
|
|
179
|
+
const len3 = WASM_VECTOR_LEN;
|
|
180
|
+
const ret = wasm.wasmmodel_chatWithMedia(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, on_delta, isLikeNone(on_prefill) ? 0 : addToExternrefTable0(on_prefill));
|
|
181
|
+
return ret;
|
|
182
|
+
}
|
|
160
183
|
/**
|
|
161
184
|
* Answers a conversation in the default session; see
|
|
162
185
|
* [`WasmSession::chat`].
|
|
@@ -244,7 +267,9 @@ export class WasmModel {
|
|
|
244
267
|
* `{ format?: "q8" | "q4" | "q4_0" | "f32" | "f16" | "bf16",
|
|
245
268
|
* contextLength?: number, deterministic?: boolean,
|
|
246
269
|
* activations?: "quantized" | "f32", device?: "cpu" | "webgpu" | "auto",
|
|
247
|
-
* adapterScale?: number, adapterMode?: "unmerged" | "merged"
|
|
270
|
+
* adapterScale?: number, adapterMode?: "unmerged" | "merged",
|
|
271
|
+
* vision?: boolean }` (`vision: false` skips the vision encoder of a
|
|
272
|
+
* vision-language checkpoint).
|
|
248
273
|
*
|
|
249
274
|
* `device` defaults to `"cpu"`. `"auto"` picks WebGPU when an adapter
|
|
250
275
|
* is available and the model has more than
|
|
@@ -263,6 +288,12 @@ export class WasmModel {
|
|
|
263
288
|
* weights: a valid stored file serves them instead of converting the
|
|
264
289
|
* checkpoint, else they are written to it as they are converted;
|
|
265
290
|
* `info().weightCache` says which (see [`WeightCacheOutcome`]).
|
|
291
|
+
*
|
|
292
|
+
* `ggufFile` loads that GGUF file of the source (a source listing
|
|
293
|
+
* GGUF files and no safetensors loads its preferred one). Without
|
|
294
|
+
* `format`, a pre-quantized checkpoint (a `Q8_0` GGUF file, a
|
|
295
|
+
* `webslm export` checkpoint) loads in its own format, its blocks
|
|
296
|
+
* unchanged; weights already in the load format skip `weightCache`.
|
|
266
297
|
* @param {JsSource} source
|
|
267
298
|
* @param {string} options_json
|
|
268
299
|
* @param {JsSource | null} [lora]
|
|
@@ -388,6 +419,34 @@ export class WasmSession {
|
|
|
388
419
|
}
|
|
389
420
|
return ret[0] >>> 0;
|
|
390
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Answers a conversation whose messages hold image or video parts
|
|
424
|
+
* (`{"type": "image"}`, `{"type": "video"}`), with a vision-language
|
|
425
|
+
* model. `media_json` describes the images and videos, one per part in
|
|
426
|
+
* order, and `media_data` holds their RGBA pixels back to back (see
|
|
427
|
+
* `webslm_bindings::media`); the `media` generation option sets the
|
|
428
|
+
* video sampling (`maxFrames`, `fps`) and processor settings. Same
|
|
429
|
+
* callbacks and result as [`WasmSession::chat`].
|
|
430
|
+
* @param {string} messages_json
|
|
431
|
+
* @param {string} options_json
|
|
432
|
+
* @param {string} media_json
|
|
433
|
+
* @param {Uint8Array} media_data
|
|
434
|
+
* @param {Function} on_delta
|
|
435
|
+
* @param {Function | null} [on_prefill]
|
|
436
|
+
* @returns {Promise<any>}
|
|
437
|
+
*/
|
|
438
|
+
chatWithMedia(messages_json, options_json, media_json, media_data, on_delta, on_prefill) {
|
|
439
|
+
const ptr0 = passStringToWasm0(messages_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
440
|
+
const len0 = WASM_VECTOR_LEN;
|
|
441
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
442
|
+
const len1 = WASM_VECTOR_LEN;
|
|
443
|
+
const ptr2 = passStringToWasm0(media_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
444
|
+
const len2 = WASM_VECTOR_LEN;
|
|
445
|
+
const ptr3 = passArray8ToWasm0(media_data, wasm.__wbindgen_malloc);
|
|
446
|
+
const len3 = WASM_VECTOR_LEN;
|
|
447
|
+
const ret = wasm.wasmsession_chatWithMedia(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, on_delta, isLikeNone(on_prefill) ? 0 : addToExternrefTable0(on_prefill));
|
|
448
|
+
return ret;
|
|
449
|
+
}
|
|
391
450
|
/**
|
|
392
451
|
* Answers a conversation: `messages_json` is a JSON array of
|
|
393
452
|
* `{ role, content }`, `options_json` a JSON object of generation
|
|
@@ -1424,33 +1483,33 @@ function __wbg_get_imports() {
|
|
|
1424
1483
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1425
1484
|
}, arguments); },
|
|
1426
1485
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1427
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1486
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 330, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1428
1487
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1429
1488
|
return ret;
|
|
1430
1489
|
},
|
|
1431
1490
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1432
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
1491
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 262, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1433
1492
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1434
1493
|
return ret;
|
|
1435
1494
|
},
|
|
1436
1495
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1437
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
1496
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 266, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1438
1497
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1439
1498
|
return ret;
|
|
1440
1499
|
},
|
|
1441
1500
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1442
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1443
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1501
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 266, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1502
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__39);
|
|
1444
1503
|
return ret;
|
|
1445
1504
|
},
|
|
1446
1505
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1447
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1448
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1506
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 262, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1507
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__40);
|
|
1449
1508
|
return ret;
|
|
1450
1509
|
},
|
|
1451
1510
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1452
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1453
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1511
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 262, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1512
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__41);
|
|
1454
1513
|
return ret;
|
|
1455
1514
|
},
|
|
1456
1515
|
__wbindgen_generic_0000000000000007: function(arg0) {
|
|
@@ -1493,8 +1552,8 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_549
|
|
|
1493
1552
|
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_(arg0, arg1, arg2);
|
|
1494
1553
|
}
|
|
1495
1554
|
|
|
1496
|
-
function
|
|
1497
|
-
wasm.
|
|
1555
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__39(arg0, arg1, arg2) {
|
|
1556
|
+
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__39(arg0, arg1, arg2);
|
|
1498
1557
|
}
|
|
1499
1558
|
|
|
1500
1559
|
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_(arg0, arg1, arg2) {
|
|
@@ -1511,15 +1570,15 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bin
|
|
|
1511
1570
|
}
|
|
1512
1571
|
}
|
|
1513
1572
|
|
|
1514
|
-
function
|
|
1515
|
-
const ret = wasm.
|
|
1573
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__40(arg0, arg1, arg2) {
|
|
1574
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__40(arg0, arg1, arg2);
|
|
1516
1575
|
if (ret[1]) {
|
|
1517
1576
|
throw takeFromExternrefTable0(ret[0]);
|
|
1518
1577
|
}
|
|
1519
1578
|
}
|
|
1520
1579
|
|
|
1521
|
-
function
|
|
1522
|
-
const ret = wasm.
|
|
1580
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__41(arg0, arg1, arg2) {
|
|
1581
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__41(arg0, arg1, arg2);
|
|
1523
1582
|
if (ret[1]) {
|
|
1524
1583
|
throw takeFromExternrefTable0(ret[0]);
|
|
1525
1584
|
}
|
|
Binary file
|
|
@@ -17,6 +17,7 @@ export const supportedModelTypes: () => [number, number];
|
|
|
17
17
|
export const version: () => [number, number];
|
|
18
18
|
export const wasmmodel_applyAdapter: (a: number, b: number, c: number, d: number) => any;
|
|
19
19
|
export const wasmmodel_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
20
|
+
export const wasmmodel_chatWithMedia: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any, k: number) => any;
|
|
20
21
|
export const wasmmodel_createSession: (a: number) => [number, number, number];
|
|
21
22
|
export const wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
22
23
|
export const wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
@@ -28,6 +29,7 @@ export const wasmmodel_reset: (a: number) => [number, number];
|
|
|
28
29
|
export const wasmmodel_tokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
29
30
|
export const wasmsession_capacity: (a: number) => [number, number, number];
|
|
30
31
|
export const wasmsession_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
32
|
+
export const wasmsession_chatWithMedia: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any, k: number) => any;
|
|
31
33
|
export const wasmsession_computed: (a: number) => [number, number, number];
|
|
32
34
|
export const wasmsession_fork: (a: number) => [number, number, number];
|
|
33
35
|
export const wasmsession_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
@@ -42,10 +44,10 @@ export const wasmsession_truncate: (a: number, b: number) => [number, number];
|
|
|
42
44
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
43
45
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
44
46
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
45
|
-
export const
|
|
46
|
-
export const
|
|
47
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__40: (a: number, b: number, c: any) => [number, number];
|
|
48
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__41: (a: number, b: number, c: any) => [number, number];
|
|
47
49
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
48
|
-
export const
|
|
50
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__39: (a: number, b: number, c: any) => void;
|
|
49
51
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
50
52
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
51
53
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
@@ -66,6 +66,11 @@ export class WasmModel {
|
|
|
66
66
|
* model. Sessions start over at their next call.
|
|
67
67
|
*/
|
|
68
68
|
applyAdapter(lora: JsSource, options_json: string): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Answers a conversation with images or videos in the default
|
|
71
|
+
* session; see [`WasmSession::chat_with_media`].
|
|
72
|
+
*/
|
|
73
|
+
chatWithMedia(messages_json: string, options_json: string, media_json: string, media_data: Uint8Array, on_delta: Function, on_prefill?: Function | null): Promise<any>;
|
|
69
74
|
/**
|
|
70
75
|
* Answers a conversation in the default session; see
|
|
71
76
|
* [`WasmSession::chat`].
|
|
@@ -93,7 +98,9 @@ export class WasmModel {
|
|
|
93
98
|
* `{ format?: "q8" | "q4" | "q4_0" | "f32" | "f16" | "bf16",
|
|
94
99
|
* contextLength?: number, deterministic?: boolean,
|
|
95
100
|
* activations?: "quantized" | "f32", device?: "cpu" | "webgpu" | "auto",
|
|
96
|
-
* adapterScale?: number, adapterMode?: "unmerged" | "merged"
|
|
101
|
+
* adapterScale?: number, adapterMode?: "unmerged" | "merged",
|
|
102
|
+
* vision?: boolean }` (`vision: false` skips the vision encoder of a
|
|
103
|
+
* vision-language checkpoint).
|
|
97
104
|
*
|
|
98
105
|
* `device` defaults to `"cpu"`. `"auto"` picks WebGPU when an adapter
|
|
99
106
|
* is available and the model has more than
|
|
@@ -112,6 +119,12 @@ export class WasmModel {
|
|
|
112
119
|
* weights: a valid stored file serves them instead of converting the
|
|
113
120
|
* checkpoint, else they are written to it as they are converted;
|
|
114
121
|
* `info().weightCache` says which (see [`WeightCacheOutcome`]).
|
|
122
|
+
*
|
|
123
|
+
* `ggufFile` loads that GGUF file of the source (a source listing
|
|
124
|
+
* GGUF files and no safetensors loads its preferred one). Without
|
|
125
|
+
* `format`, a pre-quantized checkpoint (a `Q8_0` GGUF file, a
|
|
126
|
+
* `webslm export` checkpoint) loads in its own format, its blocks
|
|
127
|
+
* unchanged; weights already in the load format skip `weightCache`.
|
|
115
128
|
*/
|
|
116
129
|
static load(source: JsSource, options_json: string, lora?: JsSource | null, weight_cache?: JsWeightCache | null): Promise<WasmModel>;
|
|
117
130
|
/**
|
|
@@ -144,6 +157,16 @@ export class WasmSession {
|
|
|
144
157
|
private constructor();
|
|
145
158
|
free(): void;
|
|
146
159
|
[Symbol.dispose](): void;
|
|
160
|
+
/**
|
|
161
|
+
* Answers a conversation whose messages hold image or video parts
|
|
162
|
+
* (`{"type": "image"}`, `{"type": "video"}`), with a vision-language
|
|
163
|
+
* model. `media_json` describes the images and videos, one per part in
|
|
164
|
+
* order, and `media_data` holds their RGBA pixels back to back (see
|
|
165
|
+
* `webslm_bindings::media`); the `media` generation option sets the
|
|
166
|
+
* video sampling (`maxFrames`, `fps`) and processor settings. Same
|
|
167
|
+
* callbacks and result as [`WasmSession::chat`].
|
|
168
|
+
*/
|
|
169
|
+
chatWithMedia(messages_json: string, options_json: string, media_json: string, media_data: Uint8Array, on_delta: Function, on_prefill?: Function | null): Promise<any>;
|
|
147
170
|
/**
|
|
148
171
|
* Answers a conversation: `messages_json` is a JSON array of
|
|
149
172
|
* `{ role, content }`, `options_json` a JSON object of generation
|
|
@@ -286,6 +309,7 @@ export interface InitOutput {
|
|
|
286
309
|
readonly version: () => [number, number];
|
|
287
310
|
readonly wasmmodel_applyAdapter: (a: number, b: number, c: number, d: number) => any;
|
|
288
311
|
readonly wasmmodel_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
312
|
+
readonly wasmmodel_chatWithMedia: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any, k: number) => any;
|
|
289
313
|
readonly wasmmodel_createSession: (a: number) => [number, number, number];
|
|
290
314
|
readonly wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
291
315
|
readonly wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
@@ -297,6 +321,7 @@ export interface InitOutput {
|
|
|
297
321
|
readonly wasmmodel_tokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
298
322
|
readonly wasmsession_capacity: (a: number) => [number, number, number];
|
|
299
323
|
readonly wasmsession_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
324
|
+
readonly wasmsession_chatWithMedia: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any, k: number) => any;
|
|
300
325
|
readonly wasmsession_computed: (a: number) => [number, number, number];
|
|
301
326
|
readonly wasmsession_fork: (a: number) => [number, number, number];
|
|
302
327
|
readonly wasmsession_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
@@ -311,10 +336,10 @@ export interface InitOutput {
|
|
|
311
336
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
312
337
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
313
338
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
314
|
-
readonly
|
|
315
|
-
readonly
|
|
339
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__40: (a: number, b: number, c: any) => [number, number];
|
|
340
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__41: (a: number, b: number, c: any) => [number, number];
|
|
316
341
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
317
|
-
readonly
|
|
342
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__39: (a: number, b: number, c: any) => void;
|
|
318
343
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
319
344
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
320
345
|
readonly __wbindgen_exn_store: (a: number) => void;
|