webslm 0.7.0 → 0.9.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 +85 -2
- package/dist/ai-sdk/embedding-model.d.ts +52 -0
- package/dist/ai-sdk/embedding-model.js +112 -0
- package/dist/ai-sdk/image-model.d.ts +53 -0
- package/dist/ai-sdk/image-model.js +148 -0
- package/dist/ai-sdk/index.d.ts +39 -0
- package/dist/ai-sdk/index.js +66 -11
- package/dist/client.d.ts +6 -0
- package/dist/client.js +8 -1
- package/dist/download.js +2 -2
- package/dist/engine.js +181 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +1 -0
- package/dist/hub.d.ts +38 -3
- package/dist/hub.js +87 -8
- package/dist/image.d.ts +201 -0
- package/dist/image.js +353 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/models.d.ts +19 -1
- package/dist/models.js +45 -6
- package/dist/native.d.ts +28 -0
- package/dist/protocol.d.ts +75 -2
- package/dist/simple.d.ts +4 -1
- package/dist/simple.js +9 -2
- package/dist/types.d.ts +39 -1
- package/dist/wasm.d.ts +2 -0
- package/native-manifest.json +29 -29
- package/package.json +1 -1
- package/wasm/relaxed/webslm_wasm.d.ts +70 -6
- package/wasm/relaxed/webslm_wasm.js +163 -18
- package/wasm/relaxed/webslm_wasm_bg.wasm +0 -0
- package/wasm/relaxed/webslm_wasm_bg.wasm.d.ts +10 -3
- package/wasm/simd/webslm_wasm.d.ts +70 -6
- package/wasm/simd/webslm_wasm.js +163 -18
- package/wasm/simd/webslm_wasm_bg.wasm +0 -0
- package/wasm/simd/webslm_wasm_bg.wasm.d.ts +10 -3
- package/wasm/threads/webslm_wasm.d.ts +71 -7
- package/wasm/threads/webslm_wasm.js +168 -23
- package/wasm/threads/webslm_wasm_bg.wasm +0 -0
- package/wasm/threads/webslm_wasm_bg.wasm.d.ts +11 -4
|
@@ -117,9 +117,89 @@ export class Sha256Hasher {
|
|
|
117
117
|
}
|
|
118
118
|
if (Symbol.dispose) Sha256Hasher.prototype[Symbol.dispose] = Sha256Hasher.prototype.free;
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* A loaded text-to-image pipeline.
|
|
122
|
+
*/
|
|
123
|
+
export class WasmImageModel {
|
|
124
|
+
static __wrap(ptr) {
|
|
125
|
+
const obj = Object.create(WasmImageModel.prototype);
|
|
126
|
+
obj.__wbg_ptr = ptr;
|
|
127
|
+
WasmImageModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
128
|
+
return obj;
|
|
129
|
+
}
|
|
130
|
+
__destroy_into_raw() {
|
|
131
|
+
const ptr = this.__wbg_ptr;
|
|
132
|
+
this.__wbg_ptr = 0;
|
|
133
|
+
WasmImageModelFinalization.unregister(this);
|
|
134
|
+
return ptr;
|
|
135
|
+
}
|
|
136
|
+
free() {
|
|
137
|
+
const ptr = this.__destroy_into_raw();
|
|
138
|
+
wasm.__wbg_wasmimagemodel_free(ptr, 0);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Generates an image of `prompt`. `options_json`: `{ width?, height?,
|
|
142
|
+
* steps?, guidance?, seed?, negativePrompt? }` (see `ImageOptionsJs`).
|
|
143
|
+
* `on_progress(phase, step, steps)` is called before encoding the
|
|
144
|
+
* prompt, before each denoising step and before decoding; returning
|
|
145
|
+
* `false` stops the generation (it rejects with `"ABORTED"`).
|
|
146
|
+
* Resolves to `{ width, height, seed, rgba: Uint8Array }` (row-major
|
|
147
|
+
* 8-bit RGBA).
|
|
148
|
+
* @param {string} prompt
|
|
149
|
+
* @param {string} options_json
|
|
150
|
+
* @param {Function | null} [on_progress]
|
|
151
|
+
* @returns {Promise<any>}
|
|
152
|
+
*/
|
|
153
|
+
generate(prompt, options_json, on_progress) {
|
|
154
|
+
const ptr0 = passStringToWasm0(prompt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
155
|
+
const len0 = WASM_VECTOR_LEN;
|
|
156
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
157
|
+
const len1 = WASM_VECTOR_LEN;
|
|
158
|
+
const ret = wasm.wasmimagemodel_generate(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
|
|
159
|
+
return ret;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Describes the pipeline (see [`ImageModelInfo`]).
|
|
163
|
+
* @returns {any}
|
|
164
|
+
*/
|
|
165
|
+
info() {
|
|
166
|
+
const ret = wasm.wasmimagemodel_info(this.__wbg_ptr);
|
|
167
|
+
if (ret[2]) {
|
|
168
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
169
|
+
}
|
|
170
|
+
return takeFromExternrefTable0(ret[0]);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Loads a pipeline from `source`. `options_json`:
|
|
174
|
+
* `{ format?: "f16" | "f32" | "bf16" | "q8" | ..., device?: "cpu" |
|
|
175
|
+
* "webgpu" | "auto" }` (defaults: f16 weights, `auto`). `decoder`,
|
|
176
|
+
* when given, serves a standalone autoencoder (`config.json` and
|
|
177
|
+
* `diffusion_pytorch_model.safetensors`, e.g. `madebyollin/taesd`)
|
|
178
|
+
* that replaces the pipeline's decoder.
|
|
179
|
+
* @param {JsSource} source
|
|
180
|
+
* @param {string} options_json
|
|
181
|
+
* @param {JsSource | null} [decoder]
|
|
182
|
+
* @returns {Promise<WasmImageModel>}
|
|
183
|
+
*/
|
|
184
|
+
static load(source, options_json, decoder) {
|
|
185
|
+
_assertClass(source, JsSource);
|
|
186
|
+
var ptr0 = source.__destroy_into_raw();
|
|
187
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
188
|
+
const len1 = WASM_VECTOR_LEN;
|
|
189
|
+
let ptr2 = 0;
|
|
190
|
+
if (!isLikeNone(decoder)) {
|
|
191
|
+
_assertClass(decoder, JsSource);
|
|
192
|
+
ptr2 = decoder.__destroy_into_raw();
|
|
193
|
+
}
|
|
194
|
+
const ret = wasm.wasmimagemodel_load(ptr0, ptr1, len1, ptr2);
|
|
195
|
+
return ret;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (Symbol.dispose) WasmImageModel.prototype[Symbol.dispose] = WasmImageModel.prototype.free;
|
|
199
|
+
|
|
120
200
|
/**
|
|
121
201
|
* A loaded checkpoint, with a default session used by `chat` and
|
|
122
|
-
* `generate`.
|
|
202
|
+
* `generate` (language models), or an encoder answering `embed`.
|
|
123
203
|
*/
|
|
124
204
|
export class WasmModel {
|
|
125
205
|
static __wrap(ptr) {
|
|
@@ -234,6 +314,27 @@ export class WasmModel {
|
|
|
234
314
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
235
315
|
}
|
|
236
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Embeds texts with an encoder. `texts_json` is a JSON array of
|
|
319
|
+
* strings; `options_json`: `{ pooling?: "cls" | "mean" | "max" |
|
|
320
|
+
* "mean_sqrt_len_tokens" | "weightedmean" | "lasttoken", normalize?:
|
|
321
|
+
* boolean }` (defaults: the model's sentence-transformers settings).
|
|
322
|
+
* Resolves to `{ data: Float32Array, dimensions: number, tokens:
|
|
323
|
+
* number[] }`: the vectors one after the other, and the number of
|
|
324
|
+
* tokens read from each text (texts longer than the model's limit are
|
|
325
|
+
* cut). Rejects with `UNSUPPORTED_TASK` on a language model.
|
|
326
|
+
* @param {string} texts_json
|
|
327
|
+
* @param {string} options_json
|
|
328
|
+
* @returns {Promise<any>}
|
|
329
|
+
*/
|
|
330
|
+
embed(texts_json, options_json) {
|
|
331
|
+
const ptr0 = passStringToWasm0(texts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
332
|
+
const len0 = WASM_VECTOR_LEN;
|
|
333
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
334
|
+
const len1 = WASM_VECTOR_LEN;
|
|
335
|
+
const ret = wasm.wasmmodel_embed(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
336
|
+
return ret;
|
|
337
|
+
}
|
|
237
338
|
/**
|
|
238
339
|
* Completes raw text in the default session; see
|
|
239
340
|
* [`WasmSession::generate`].
|
|
@@ -262,6 +363,14 @@ export class WasmModel {
|
|
|
262
363
|
}
|
|
263
364
|
return takeFromExternrefTable0(ret[0]);
|
|
264
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Whether the model is an encoder (it answers `embed`, not `chat`).
|
|
368
|
+
* @returns {boolean}
|
|
369
|
+
*/
|
|
370
|
+
get isEncoder() {
|
|
371
|
+
const ret = wasm.wasmmodel_isEncoder(this.__wbg_ptr);
|
|
372
|
+
return ret !== 0;
|
|
373
|
+
}
|
|
265
374
|
/**
|
|
266
375
|
* Loads a checkpoint from `source`. `options_json` is a JSON object:
|
|
267
376
|
* `{ format?: "q8" | "q4" | "q4_0" | "f32" | "f16" | "bf16",
|
|
@@ -295,6 +404,9 @@ export class WasmModel {
|
|
|
295
404
|
* `format`, a pre-quantized checkpoint (a `Q8_0` GGUF file, a
|
|
296
405
|
* `webslm export` checkpoint) loads in its own format, its blocks
|
|
297
406
|
* unchanged; weights already in the load format skip `weightCache`.
|
|
407
|
+
*
|
|
408
|
+
* An encoder loads in f32 unless `format` says otherwise, and takes
|
|
409
|
+
* no `lora`.
|
|
298
410
|
* @param {JsSource} source
|
|
299
411
|
* @param {string} options_json
|
|
300
412
|
* @param {JsSource | null} [lora]
|
|
@@ -361,7 +473,7 @@ export class WasmModel {
|
|
|
361
473
|
}
|
|
362
474
|
}
|
|
363
475
|
/**
|
|
364
|
-
* Clears the default session.
|
|
476
|
+
* Clears the default session (nothing to clear for an encoder).
|
|
365
477
|
*/
|
|
366
478
|
reset() {
|
|
367
479
|
const ret = wasm.wasmmodel_reset(this.__wbg_ptr);
|
|
@@ -370,7 +482,8 @@ export class WasmModel {
|
|
|
370
482
|
}
|
|
371
483
|
}
|
|
372
484
|
/**
|
|
373
|
-
* Encodes text into token ids
|
|
485
|
+
* Encodes text into token ids (an encoder's tokenizer cuts texts at
|
|
486
|
+
* its limit, as `embed` does).
|
|
374
487
|
* @param {string} text
|
|
375
488
|
* @param {boolean} add_special_tokens
|
|
376
489
|
* @returns {Uint32Array}
|
|
@@ -669,6 +782,18 @@ export function parseSafetensorsHeader(bytes) {
|
|
|
669
782
|
return takeFromExternrefTable0(ret[0]);
|
|
670
783
|
}
|
|
671
784
|
|
|
785
|
+
/**
|
|
786
|
+
* `model_type` values of the encoders this build embeds with (models
|
|
787
|
+
* whose `WasmModel` answers `embed`).
|
|
788
|
+
* @returns {string[]}
|
|
789
|
+
*/
|
|
790
|
+
export function supportedEncoderTypes() {
|
|
791
|
+
const ret = wasm.supportedEncoderTypes();
|
|
792
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
793
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
794
|
+
return v1;
|
|
795
|
+
}
|
|
796
|
+
|
|
672
797
|
/**
|
|
673
798
|
* `model_type` values (from `config.json`) of the architectures this build
|
|
674
799
|
* can run.
|
|
@@ -719,6 +844,11 @@ function __wbg_get_imports() {
|
|
|
719
844
|
const ret = arg0.WorkerGlobalScope;
|
|
720
845
|
return ret;
|
|
721
846
|
},
|
|
847
|
+
__wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
|
|
848
|
+
const v = arg0;
|
|
849
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
850
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
851
|
+
},
|
|
722
852
|
__wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
|
|
723
853
|
const ret = debugString(arg1);
|
|
724
854
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -1148,6 +1278,10 @@ function __wbg_get_imports() {
|
|
|
1148
1278
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1149
1279
|
return ret;
|
|
1150
1280
|
},
|
|
1281
|
+
__wbg_new_from_slice_a500ec81601be48f: function(arg0, arg1) {
|
|
1282
|
+
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
1283
|
+
return ret;
|
|
1284
|
+
},
|
|
1151
1285
|
__wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
|
|
1152
1286
|
try {
|
|
1153
1287
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -1211,6 +1345,10 @@ function __wbg_get_imports() {
|
|
|
1211
1345
|
const ret = arg0.reason;
|
|
1212
1346
|
return (__wbindgen_enum_GpuDeviceLostReason.indexOf(ret) + 1 || 3) - 1;
|
|
1213
1347
|
},
|
|
1348
|
+
__wbg_reject_bea6d825081bd4d7: function(arg0) {
|
|
1349
|
+
const ret = Promise.reject(arg0);
|
|
1350
|
+
return ret;
|
|
1351
|
+
},
|
|
1214
1352
|
__wbg_requestAdapter_2cb1006baf7abd60: function(arg0) {
|
|
1215
1353
|
const ret = arg0.requestAdapter();
|
|
1216
1354
|
return ret;
|
|
@@ -1476,6 +1614,10 @@ function __wbg_get_imports() {
|
|
|
1476
1614
|
const ret = arg0.valueOf();
|
|
1477
1615
|
return ret;
|
|
1478
1616
|
},
|
|
1617
|
+
__wbg_wasmimagemodel_new: function(arg0) {
|
|
1618
|
+
const ret = WasmImageModel.__wrap(arg0);
|
|
1619
|
+
return ret;
|
|
1620
|
+
},
|
|
1479
1621
|
__wbg_wasmmodel_new: function(arg0) {
|
|
1480
1622
|
const ret = WasmModel.__wrap(arg0);
|
|
1481
1623
|
return ret;
|
|
@@ -1484,33 +1626,33 @@ function __wbg_get_imports() {
|
|
|
1484
1626
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1485
1627
|
}, arguments); },
|
|
1486
1628
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1487
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1629
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 361, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1488
1630
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1489
1631
|
return ret;
|
|
1490
1632
|
},
|
|
1491
1633
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1492
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
1634
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 290, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1493
1635
|
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_);
|
|
1494
1636
|
return ret;
|
|
1495
1637
|
},
|
|
1496
1638
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1497
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
1639
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 294, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1498
1640
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1499
1641
|
return ret;
|
|
1500
1642
|
},
|
|
1501
1643
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1502
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1503
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1644
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 294, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1645
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__45);
|
|
1504
1646
|
return ret;
|
|
1505
1647
|
},
|
|
1506
1648
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1507
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1508
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1649
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 290, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1650
|
+
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__46);
|
|
1509
1651
|
return ret;
|
|
1510
1652
|
},
|
|
1511
1653
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1512
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1513
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1654
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 290, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1655
|
+
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__47);
|
|
1514
1656
|
return ret;
|
|
1515
1657
|
},
|
|
1516
1658
|
__wbindgen_generic_0000000000000007: function(arg0) {
|
|
@@ -1553,8 +1695,8 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_549
|
|
|
1553
1695
|
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_(arg0, arg1, arg2);
|
|
1554
1696
|
}
|
|
1555
1697
|
|
|
1556
|
-
function
|
|
1557
|
-
wasm.
|
|
1698
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__45(arg0, arg1, arg2) {
|
|
1699
|
+
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__45(arg0, arg1, arg2);
|
|
1558
1700
|
}
|
|
1559
1701
|
|
|
1560
1702
|
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_(arg0, arg1, arg2) {
|
|
@@ -1571,15 +1713,15 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bin
|
|
|
1571
1713
|
}
|
|
1572
1714
|
}
|
|
1573
1715
|
|
|
1574
|
-
function
|
|
1575
|
-
const ret = wasm.
|
|
1716
|
+
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__46(arg0, arg1, arg2) {
|
|
1717
|
+
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__46(arg0, arg1, arg2);
|
|
1576
1718
|
if (ret[1]) {
|
|
1577
1719
|
throw takeFromExternrefTable0(ret[0]);
|
|
1578
1720
|
}
|
|
1579
1721
|
}
|
|
1580
1722
|
|
|
1581
|
-
function
|
|
1582
|
-
const ret = wasm.
|
|
1723
|
+
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__47(arg0, arg1, arg2) {
|
|
1724
|
+
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__47(arg0, arg1, arg2);
|
|
1583
1725
|
if (ret[1]) {
|
|
1584
1726
|
throw takeFromExternrefTable0(ret[0]);
|
|
1585
1727
|
}
|
|
@@ -1627,6 +1769,9 @@ const JsWeightCacheFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1627
1769
|
const Sha256HasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1628
1770
|
? { register: () => {}, unregister: () => {} }
|
|
1629
1771
|
: new FinalizationRegistry(ptr => wasm.__wbg_sha256hasher_free(ptr, 1));
|
|
1772
|
+
const WasmImageModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1773
|
+
? { register: () => {}, unregister: () => {} }
|
|
1774
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmimagemodel_free(ptr, 1));
|
|
1630
1775
|
const WasmModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1631
1776
|
? { register: () => {}, unregister: () => {} }
|
|
1632
1777
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmodel_free(ptr, 1));
|
|
Binary file
|
|
@@ -4,6 +4,7 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const __wbg_jssource_free: (a: number, b: number) => void;
|
|
5
5
|
export const __wbg_jsweightcache_free: (a: number, b: number) => void;
|
|
6
6
|
export const __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
7
|
+
export const __wbg_wasmimagemodel_free: (a: number, b: number) => void;
|
|
7
8
|
export const __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
8
9
|
export const __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
9
10
|
export const buildInfo: () => [number, number, number];
|
|
@@ -13,15 +14,21 @@ export const parseSafetensorsHeader: (a: number, b: number) => [number, number,
|
|
|
13
14
|
export const sha256hasher_finish: (a: number) => [number, number];
|
|
14
15
|
export const sha256hasher_new: () => number;
|
|
15
16
|
export const sha256hasher_update: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const supportedEncoderTypes: () => [number, number];
|
|
16
18
|
export const supportedModelTypes: () => [number, number];
|
|
17
19
|
export const version: () => [number, number];
|
|
20
|
+
export const wasmimagemodel_generate: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
21
|
+
export const wasmimagemodel_info: (a: number) => [number, number, number];
|
|
22
|
+
export const wasmimagemodel_load: (a: number, b: number, c: number, d: number) => any;
|
|
18
23
|
export const wasmmodel_applyAdapter: (a: number, b: number, c: number, d: number) => any;
|
|
19
24
|
export const wasmmodel_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
20
25
|
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;
|
|
21
26
|
export const wasmmodel_createSession: (a: number) => [number, number, number];
|
|
22
27
|
export const wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
28
|
+
export const wasmmodel_embed: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
23
29
|
export const wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
24
30
|
export const wasmmodel_info: (a: number) => [number, number, number];
|
|
31
|
+
export const wasmmodel_isEncoder: (a: number) => number;
|
|
25
32
|
export const wasmmodel_load: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
26
33
|
export const wasmmodel_removeAdapter: (a: number) => any;
|
|
27
34
|
export const wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
@@ -44,10 +51,10 @@ export const wasmsession_truncate: (a: number, b: number) => [number, number];
|
|
|
44
51
|
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;
|
|
45
52
|
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];
|
|
46
53
|
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];
|
|
47
|
-
export const
|
|
48
|
-
export const
|
|
54
|
+
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__46: (a: number, b: number, c: any) => [number, number];
|
|
55
|
+
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__47: (a: number, b: number, c: any) => [number, number];
|
|
49
56
|
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;
|
|
50
|
-
export const
|
|
57
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__45: (a: number, b: number, c: any) => void;
|
|
51
58
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
52
59
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
53
60
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
@@ -49,9 +49,41 @@ export class Sha256Hasher {
|
|
|
49
49
|
update(bytes: Uint8Array): void;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* A loaded text-to-image pipeline.
|
|
54
|
+
*/
|
|
55
|
+
export class WasmImageModel {
|
|
56
|
+
private constructor();
|
|
57
|
+
free(): void;
|
|
58
|
+
[Symbol.dispose](): void;
|
|
59
|
+
/**
|
|
60
|
+
* Generates an image of `prompt`. `options_json`: `{ width?, height?,
|
|
61
|
+
* steps?, guidance?, seed?, negativePrompt? }` (see `ImageOptionsJs`).
|
|
62
|
+
* `on_progress(phase, step, steps)` is called before encoding the
|
|
63
|
+
* prompt, before each denoising step and before decoding; returning
|
|
64
|
+
* `false` stops the generation (it rejects with `"ABORTED"`).
|
|
65
|
+
* Resolves to `{ width, height, seed, rgba: Uint8Array }` (row-major
|
|
66
|
+
* 8-bit RGBA).
|
|
67
|
+
*/
|
|
68
|
+
generate(prompt: string, options_json: string, on_progress?: Function | null): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Describes the pipeline (see [`ImageModelInfo`]).
|
|
71
|
+
*/
|
|
72
|
+
info(): any;
|
|
73
|
+
/**
|
|
74
|
+
* Loads a pipeline from `source`. `options_json`:
|
|
75
|
+
* `{ format?: "f16" | "f32" | "bf16" | "q8" | ..., device?: "cpu" |
|
|
76
|
+
* "webgpu" | "auto" }` (defaults: f16 weights, `auto`). `decoder`,
|
|
77
|
+
* when given, serves a standalone autoencoder (`config.json` and
|
|
78
|
+
* `diffusion_pytorch_model.safetensors`, e.g. `madebyollin/taesd`)
|
|
79
|
+
* that replaces the pipeline's decoder.
|
|
80
|
+
*/
|
|
81
|
+
static load(source: JsSource, options_json: string, decoder?: JsSource | null): Promise<WasmImageModel>;
|
|
82
|
+
}
|
|
83
|
+
|
|
52
84
|
/**
|
|
53
85
|
* A loaded checkpoint, with a default session used by `chat` and
|
|
54
|
-
* `generate`.
|
|
86
|
+
* `generate` (language models), or an encoder answering `embed`.
|
|
55
87
|
*/
|
|
56
88
|
export class WasmModel {
|
|
57
89
|
private constructor();
|
|
@@ -84,6 +116,17 @@ export class WasmModel {
|
|
|
84
116
|
* Decodes token ids into text.
|
|
85
117
|
*/
|
|
86
118
|
detokenize(ids: Uint32Array, skip_special_tokens: boolean): string;
|
|
119
|
+
/**
|
|
120
|
+
* Embeds texts with an encoder. `texts_json` is a JSON array of
|
|
121
|
+
* strings; `options_json`: `{ pooling?: "cls" | "mean" | "max" |
|
|
122
|
+
* "mean_sqrt_len_tokens" | "weightedmean" | "lasttoken", normalize?:
|
|
123
|
+
* boolean }` (defaults: the model's sentence-transformers settings).
|
|
124
|
+
* Resolves to `{ data: Float32Array, dimensions: number, tokens:
|
|
125
|
+
* number[] }`: the vectors one after the other, and the number of
|
|
126
|
+
* tokens read from each text (texts longer than the model's limit are
|
|
127
|
+
* cut). Rejects with `UNSUPPORTED_TASK` on a language model.
|
|
128
|
+
*/
|
|
129
|
+
embed(texts_json: string, options_json: string): Promise<any>;
|
|
87
130
|
/**
|
|
88
131
|
* Completes raw text in the default session; see
|
|
89
132
|
* [`WasmSession::generate`].
|
|
@@ -126,6 +169,9 @@ export class WasmModel {
|
|
|
126
169
|
* `format`, a pre-quantized checkpoint (a `Q8_0` GGUF file, a
|
|
127
170
|
* `webslm export` checkpoint) loads in its own format, its blocks
|
|
128
171
|
* unchanged; weights already in the load format skip `weightCache`.
|
|
172
|
+
*
|
|
173
|
+
* An encoder loads in f32 unless `format` says otherwise, and takes
|
|
174
|
+
* no `lora`.
|
|
129
175
|
*/
|
|
130
176
|
static load(source: JsSource, options_json: string, lora?: JsSource | null, weight_cache?: JsWeightCache | null): Promise<WasmModel>;
|
|
131
177
|
/**
|
|
@@ -142,13 +188,18 @@ export class WasmModel {
|
|
|
142
188
|
*/
|
|
143
189
|
renderChat(messages_json: string, kwargs_json: string): string;
|
|
144
190
|
/**
|
|
145
|
-
* Clears the default session.
|
|
191
|
+
* Clears the default session (nothing to clear for an encoder).
|
|
146
192
|
*/
|
|
147
193
|
reset(): void;
|
|
148
194
|
/**
|
|
149
|
-
* Encodes text into token ids
|
|
195
|
+
* Encodes text into token ids (an encoder's tokenizer cuts texts at
|
|
196
|
+
* its limit, as `embed` does).
|
|
150
197
|
*/
|
|
151
198
|
tokenize(text: string, add_special_tokens: boolean): Uint32Array;
|
|
199
|
+
/**
|
|
200
|
+
* Whether the model is an encoder (it answers `embed`, not `chat`).
|
|
201
|
+
*/
|
|
202
|
+
readonly isEncoder: boolean;
|
|
152
203
|
}
|
|
153
204
|
|
|
154
205
|
/**
|
|
@@ -279,6 +330,12 @@ export function buildInfo(): any;
|
|
|
279
330
|
*/
|
|
280
331
|
export function parseSafetensorsHeader(bytes: Uint8Array): any;
|
|
281
332
|
|
|
333
|
+
/**
|
|
334
|
+
* `model_type` values of the encoders this build embeds with (models
|
|
335
|
+
* whose `WasmModel` answers `embed`).
|
|
336
|
+
*/
|
|
337
|
+
export function supportedEncoderTypes(): string[];
|
|
338
|
+
|
|
282
339
|
/**
|
|
283
340
|
* `model_type` values (from `config.json`) of the architectures this build
|
|
284
341
|
* can run.
|
|
@@ -297,6 +354,7 @@ export interface InitOutput {
|
|
|
297
354
|
readonly __wbg_jssource_free: (a: number, b: number) => void;
|
|
298
355
|
readonly __wbg_jsweightcache_free: (a: number, b: number) => void;
|
|
299
356
|
readonly __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
357
|
+
readonly __wbg_wasmimagemodel_free: (a: number, b: number) => void;
|
|
300
358
|
readonly __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
301
359
|
readonly __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
302
360
|
readonly buildInfo: () => [number, number, number];
|
|
@@ -306,15 +364,21 @@ export interface InitOutput {
|
|
|
306
364
|
readonly sha256hasher_finish: (a: number) => [number, number];
|
|
307
365
|
readonly sha256hasher_new: () => number;
|
|
308
366
|
readonly sha256hasher_update: (a: number, b: number, c: number) => void;
|
|
367
|
+
readonly supportedEncoderTypes: () => [number, number];
|
|
309
368
|
readonly supportedModelTypes: () => [number, number];
|
|
310
369
|
readonly version: () => [number, number];
|
|
370
|
+
readonly wasmimagemodel_generate: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
371
|
+
readonly wasmimagemodel_info: (a: number) => [number, number, number];
|
|
372
|
+
readonly wasmimagemodel_load: (a: number, b: number, c: number, d: number) => any;
|
|
311
373
|
readonly wasmmodel_applyAdapter: (a: number, b: number, c: number, d: number) => any;
|
|
312
374
|
readonly wasmmodel_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
313
375
|
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;
|
|
314
376
|
readonly wasmmodel_createSession: (a: number) => [number, number, number];
|
|
315
377
|
readonly wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
378
|
+
readonly wasmmodel_embed: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
316
379
|
readonly wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
317
380
|
readonly wasmmodel_info: (a: number) => [number, number, number];
|
|
381
|
+
readonly wasmmodel_isEncoder: (a: number) => number;
|
|
318
382
|
readonly wasmmodel_load: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
319
383
|
readonly wasmmodel_removeAdapter: (a: number) => any;
|
|
320
384
|
readonly wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
@@ -337,10 +401,10 @@ export interface InitOutput {
|
|
|
337
401
|
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;
|
|
338
402
|
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];
|
|
339
403
|
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];
|
|
340
|
-
readonly
|
|
341
|
-
readonly
|
|
404
|
+
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__46: (a: number, b: number, c: any) => [number, number];
|
|
405
|
+
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__47: (a: number, b: number, c: any) => [number, number];
|
|
342
406
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
343
|
-
readonly
|
|
407
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__45: (a: number, b: number, c: any) => void;
|
|
344
408
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
345
409
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
346
410
|
readonly __wbindgen_exn_store: (a: number) => void;
|