webslm 0.7.0 → 0.10.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.
Files changed (45) hide show
  1. package/README.md +116 -2
  2. package/dist/ai-sdk/embedding-model.d.ts +52 -0
  3. package/dist/ai-sdk/embedding-model.js +112 -0
  4. package/dist/ai-sdk/image-model.d.ts +53 -0
  5. package/dist/ai-sdk/image-model.js +148 -0
  6. package/dist/ai-sdk/index.d.ts +54 -0
  7. package/dist/ai-sdk/index.js +85 -11
  8. package/dist/ai-sdk/transcription-model.d.ts +48 -0
  9. package/dist/ai-sdk/transcription-model.js +115 -0
  10. package/dist/audio.d.ts +33 -0
  11. package/dist/audio.js +87 -0
  12. package/dist/client.d.ts +6 -0
  13. package/dist/client.js +8 -1
  14. package/dist/download.js +2 -2
  15. package/dist/engine.js +233 -0
  16. package/dist/errors.d.ts +5 -0
  17. package/dist/errors.js +1 -0
  18. package/dist/hub.d.ts +47 -3
  19. package/dist/hub.js +97 -8
  20. package/dist/image.d.ts +201 -0
  21. package/dist/image.js +353 -0
  22. package/dist/index.d.ts +6 -3
  23. package/dist/index.js +5 -2
  24. package/dist/models.d.ts +37 -1
  25. package/dist/models.js +99 -6
  26. package/dist/native.d.ts +34 -0
  27. package/dist/protocol.d.ts +106 -2
  28. package/dist/simple.d.ts +4 -1
  29. package/dist/simple.js +9 -2
  30. package/dist/types.d.ts +107 -1
  31. package/dist/wasm.d.ts +4 -0
  32. package/native-manifest.json +29 -29
  33. package/package.json +1 -1
  34. package/wasm/relaxed/webslm_wasm.d.ts +97 -6
  35. package/wasm/relaxed/webslm_wasm.js +223 -18
  36. package/wasm/relaxed/webslm_wasm_bg.wasm +0 -0
  37. package/wasm/relaxed/webslm_wasm_bg.wasm.d.ts +13 -3
  38. package/wasm/simd/webslm_wasm.d.ts +97 -6
  39. package/wasm/simd/webslm_wasm.js +223 -18
  40. package/wasm/simd/webslm_wasm_bg.wasm +0 -0
  41. package/wasm/simd/webslm_wasm_bg.wasm.d.ts +13 -3
  42. package/wasm/threads/webslm_wasm.d.ts +98 -7
  43. package/wasm/threads/webslm_wasm.js +228 -23
  44. package/wasm/threads/webslm_wasm_bg.wasm +0 -0
  45. package/wasm/threads/webslm_wasm_bg.wasm.d.ts +14 -4
@@ -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,36 @@ 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
+ * Transcribes speech with a speech recognition model (Whisper).
201
+ * `audio` is mono PCM (`Float32Array`, at `sampleRate`, 16 kHz by
202
+ * default) or the bytes of a WAV file (`Uint8Array`; browsers decode
203
+ * other formats with `AudioContext` first). `options_json`:
204
+ * `{ language?: string, task?: "transcribe" | "translate",
205
+ * maxNewTokens?: number, sampleRate?: number }` (no language: detected).
206
+ * `on_text(text)` receives the text as it is generated and stops the
207
+ * transcription by returning `false` (or a promise resolving to
208
+ * `false`). Resolves to `{ text, language,
209
+ * duration, segments: [{ id, start, end, text, tokens }], tokens,
210
+ * stopped }`. Rejects with `UNSUPPORTED_TASK` on other models.
211
+ */
212
+ transcribe(audio: any, options_json: string, on_text?: Function | null): Promise<any>;
213
+ /**
214
+ * Whether the model is an encoder (it answers `embed`, not `chat`).
215
+ */
216
+ readonly isEncoder: boolean;
217
+ /**
218
+ * Whether the model recognizes speech (it answers `transcribe`).
219
+ */
220
+ readonly isSpeech: boolean;
152
221
  }
153
222
 
154
223
  /**
@@ -288,12 +357,24 @@ export function parseSafetensorsHeader(bytes: Uint8Array): any;
288
357
  */
289
358
  export function startThreadPool(threads: number): Promise<void>;
290
359
 
360
+ /**
361
+ * `model_type` values of the encoders this build embeds with (models
362
+ * whose `WasmModel` answers `embed`).
363
+ */
364
+ export function supportedEncoderTypes(): string[];
365
+
291
366
  /**
292
367
  * `model_type` values (from `config.json`) of the architectures this build
293
368
  * can run.
294
369
  */
295
370
  export function supportedModelTypes(): string[];
296
371
 
372
+ /**
373
+ * `model_type` values of the speech recognition models this build runs
374
+ * (models whose `WasmModel` answers `transcribe`).
375
+ */
376
+ export function supportedSpeechTypes(): string[];
377
+
297
378
  /**
298
379
  * Version of the Rust engine, as declared in `Cargo.toml`.
299
380
  */
@@ -316,6 +397,7 @@ export interface InitOutput {
316
397
  readonly __wbg_jssource_free: (a: number, b: number) => void;
317
398
  readonly __wbg_jsweightcache_free: (a: number, b: number) => void;
318
399
  readonly __wbg_sha256hasher_free: (a: number, b: number) => void;
400
+ readonly __wbg_wasmimagemodel_free: (a: number, b: number) => void;
319
401
  readonly __wbg_wasmmodel_free: (a: number, b: number) => void;
320
402
  readonly __wbg_wasmsession_free: (a: number, b: number) => void;
321
403
  readonly __wbg_wbg_rayon_poolbuilder_free: (a: number, b: number) => void;
@@ -328,20 +410,29 @@ export interface InitOutput {
328
410
  readonly sha256hasher_new: () => number;
329
411
  readonly sha256hasher_update: (a: number, b: number, c: number) => void;
330
412
  readonly startThreadPool: (a: number) => any;
413
+ readonly supportedEncoderTypes: () => [number, number];
331
414
  readonly supportedModelTypes: () => [number, number];
415
+ readonly supportedSpeechTypes: () => [number, number];
332
416
  readonly version: () => [number, number];
417
+ readonly wasmimagemodel_generate: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
418
+ readonly wasmimagemodel_info: (a: number) => [number, number, number];
419
+ readonly wasmimagemodel_load: (a: number, b: number, c: number, d: number) => any;
333
420
  readonly wasmmodel_applyAdapter: (a: number, b: number, c: number, d: number) => any;
334
421
  readonly wasmmodel_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
335
422
  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;
336
423
  readonly wasmmodel_createSession: (a: number) => [number, number, number];
337
424
  readonly wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
425
+ readonly wasmmodel_embed: (a: number, b: number, c: number, d: number, e: number) => any;
338
426
  readonly wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
339
427
  readonly wasmmodel_info: (a: number) => [number, number, number];
428
+ readonly wasmmodel_isEncoder: (a: number) => number;
429
+ readonly wasmmodel_isSpeech: (a: number) => number;
340
430
  readonly wasmmodel_load: (a: number, b: number, c: number, d: number, e: number) => any;
341
431
  readonly wasmmodel_removeAdapter: (a: number) => any;
342
432
  readonly wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
343
433
  readonly wasmmodel_reset: (a: number) => [number, number];
344
434
  readonly wasmmodel_tokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
435
+ readonly wasmmodel_transcribe: (a: number, b: any, c: number, d: number, e: number) => any;
345
436
  readonly wasmsession_capacity: (a: number) => [number, number, number];
346
437
  readonly wasmsession_chat: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
347
438
  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;
@@ -363,12 +454,12 @@ export interface InitOutput {
363
454
  readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___Function_fn_wasm_bindgen_3c612a990bfab728___JsValue_____wasm_bindgen_3c612a990bfab728___sys__Undefined___js_sys_b608be85a12bc1d0___Function_fn_wasm_bindgen_3c612a990bfab728___JsValue_____wasm_bindgen_3c612a990bfab728___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
364
455
  readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue__core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_: (a: number, b: number, c: any) => [number, number];
365
456
  readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_: (a: number, b: number, c: any) => [number, number];
366
- readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__48: (a: number, b: number, c: any) => [number, number];
367
- readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__49: (a: number, b: number, c: any) => [number, number];
457
+ readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__57: (a: number, b: number, c: any) => [number, number];
458
+ readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__58: (a: number, b: number, c: any) => [number, number];
368
459
  readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___futures__task__wait_async_polyfill__MessageEvent______true_: (a: number, b: number, c: any) => void;
369
460
  readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true_: (a: number, b: number, c: any) => void;
370
- readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__46: (a: number, b: number, c: any) => void;
371
- readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__47: (a: number, b: number, c: any) => void;
461
+ readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__55: (a: number, b: number, c: any) => void;
462
+ readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__56: (a: number, b: number, c: any) => void;
372
463
  readonly memory: WebAssembly.Memory;
373
464
  readonly __wbindgen_malloc: (a: number, b: number) => number;
374
465
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
@@ -119,9 +119,89 @@ export class Sha256Hasher {
119
119
  }
120
120
  if (Symbol.dispose) Sha256Hasher.prototype[Symbol.dispose] = Sha256Hasher.prototype.free;
121
121
 
122
+ /**
123
+ * A loaded text-to-image pipeline.
124
+ */
125
+ export class WasmImageModel {
126
+ static __wrap(ptr) {
127
+ const obj = Object.create(WasmImageModel.prototype);
128
+ obj.__wbg_ptr = ptr;
129
+ WasmImageModelFinalization.register(obj, obj.__wbg_ptr, obj);
130
+ return obj;
131
+ }
132
+ __destroy_into_raw() {
133
+ const ptr = this.__wbg_ptr;
134
+ this.__wbg_ptr = 0;
135
+ WasmImageModelFinalization.unregister(this);
136
+ return ptr;
137
+ }
138
+ free() {
139
+ const ptr = this.__destroy_into_raw();
140
+ wasm.__wbg_wasmimagemodel_free(ptr, 0);
141
+ }
142
+ /**
143
+ * Generates an image of `prompt`. `options_json`: `{ width?, height?,
144
+ * steps?, guidance?, seed?, negativePrompt? }` (see `ImageOptionsJs`).
145
+ * `on_progress(phase, step, steps)` is called before encoding the
146
+ * prompt, before each denoising step and before decoding; returning
147
+ * `false` stops the generation (it rejects with `"ABORTED"`).
148
+ * Resolves to `{ width, height, seed, rgba: Uint8Array }` (row-major
149
+ * 8-bit RGBA).
150
+ * @param {string} prompt
151
+ * @param {string} options_json
152
+ * @param {Function | null} [on_progress]
153
+ * @returns {Promise<any>}
154
+ */
155
+ generate(prompt, options_json, on_progress) {
156
+ const ptr0 = passStringToWasm0(prompt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ const len0 = WASM_VECTOR_LEN;
158
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len1 = WASM_VECTOR_LEN;
160
+ const ret = wasm.wasmimagemodel_generate(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
161
+ return ret;
162
+ }
163
+ /**
164
+ * Describes the pipeline (see [`ImageModelInfo`]).
165
+ * @returns {any}
166
+ */
167
+ info() {
168
+ const ret = wasm.wasmimagemodel_info(this.__wbg_ptr);
169
+ if (ret[2]) {
170
+ throw takeFromExternrefTable0(ret[1]);
171
+ }
172
+ return takeFromExternrefTable0(ret[0]);
173
+ }
174
+ /**
175
+ * Loads a pipeline from `source`. `options_json`:
176
+ * `{ format?: "f16" | "f32" | "bf16" | "q8" | ..., device?: "cpu" |
177
+ * "webgpu" | "auto" }` (defaults: f16 weights, `auto`). `decoder`,
178
+ * when given, serves a standalone autoencoder (`config.json` and
179
+ * `diffusion_pytorch_model.safetensors`, e.g. `madebyollin/taesd`)
180
+ * that replaces the pipeline's decoder.
181
+ * @param {JsSource} source
182
+ * @param {string} options_json
183
+ * @param {JsSource | null} [decoder]
184
+ * @returns {Promise<WasmImageModel>}
185
+ */
186
+ static load(source, options_json, decoder) {
187
+ _assertClass(source, JsSource);
188
+ var ptr0 = source.__destroy_into_raw();
189
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ const len1 = WASM_VECTOR_LEN;
191
+ let ptr2 = 0;
192
+ if (!isLikeNone(decoder)) {
193
+ _assertClass(decoder, JsSource);
194
+ ptr2 = decoder.__destroy_into_raw();
195
+ }
196
+ const ret = wasm.wasmimagemodel_load(ptr0, ptr1, len1, ptr2);
197
+ return ret;
198
+ }
199
+ }
200
+ if (Symbol.dispose) WasmImageModel.prototype[Symbol.dispose] = WasmImageModel.prototype.free;
201
+
122
202
  /**
123
203
  * A loaded checkpoint, with a default session used by `chat` and
124
- * `generate`.
204
+ * `generate` (language models), or an encoder answering `embed`.
125
205
  */
126
206
  export class WasmModel {
127
207
  static __wrap(ptr) {
@@ -236,6 +316,27 @@ export class WasmModel {
236
316
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
237
317
  }
238
318
  }
319
+ /**
320
+ * Embeds texts with an encoder. `texts_json` is a JSON array of
321
+ * strings; `options_json`: `{ pooling?: "cls" | "mean" | "max" |
322
+ * "mean_sqrt_len_tokens" | "weightedmean" | "lasttoken", normalize?:
323
+ * boolean }` (defaults: the model's sentence-transformers settings).
324
+ * Resolves to `{ data: Float32Array, dimensions: number, tokens:
325
+ * number[] }`: the vectors one after the other, and the number of
326
+ * tokens read from each text (texts longer than the model's limit are
327
+ * cut). Rejects with `UNSUPPORTED_TASK` on a language model.
328
+ * @param {string} texts_json
329
+ * @param {string} options_json
330
+ * @returns {Promise<any>}
331
+ */
332
+ embed(texts_json, options_json) {
333
+ const ptr0 = passStringToWasm0(texts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
+ const len0 = WASM_VECTOR_LEN;
335
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
336
+ const len1 = WASM_VECTOR_LEN;
337
+ const ret = wasm.wasmmodel_embed(this.__wbg_ptr, ptr0, len0, ptr1, len1);
338
+ return ret;
339
+ }
239
340
  /**
240
341
  * Completes raw text in the default session; see
241
342
  * [`WasmSession::generate`].
@@ -264,6 +365,22 @@ export class WasmModel {
264
365
  }
265
366
  return takeFromExternrefTable0(ret[0]);
266
367
  }
368
+ /**
369
+ * Whether the model is an encoder (it answers `embed`, not `chat`).
370
+ * @returns {boolean}
371
+ */
372
+ get isEncoder() {
373
+ const ret = wasm.wasmmodel_isEncoder(this.__wbg_ptr);
374
+ return ret !== 0;
375
+ }
376
+ /**
377
+ * Whether the model recognizes speech (it answers `transcribe`).
378
+ * @returns {boolean}
379
+ */
380
+ get isSpeech() {
381
+ const ret = wasm.wasmmodel_isSpeech(this.__wbg_ptr);
382
+ return ret !== 0;
383
+ }
267
384
  /**
268
385
  * Loads a checkpoint from `source`. `options_json` is a JSON object:
269
386
  * `{ format?: "q8" | "q4" | "q4_0" | "f32" | "f16" | "bf16",
@@ -297,6 +414,9 @@ export class WasmModel {
297
414
  * `format`, a pre-quantized checkpoint (a `Q8_0` GGUF file, a
298
415
  * `webslm export` checkpoint) loads in its own format, its blocks
299
416
  * unchanged; weights already in the load format skip `weightCache`.
417
+ *
418
+ * An encoder loads in f32 unless `format` says otherwise, and takes
419
+ * no `lora`.
300
420
  * @param {JsSource} source
301
421
  * @param {string} options_json
302
422
  * @param {JsSource | null} [lora]
@@ -363,7 +483,7 @@ export class WasmModel {
363
483
  }
364
484
  }
365
485
  /**
366
- * Clears the default session.
486
+ * Clears the default session (nothing to clear for an encoder).
367
487
  */
368
488
  reset() {
369
489
  const ret = wasm.wasmmodel_reset(this.__wbg_ptr);
@@ -372,7 +492,8 @@ export class WasmModel {
372
492
  }
373
493
  }
374
494
  /**
375
- * Encodes text into token ids.
495
+ * Encodes text into token ids (an encoder's tokenizer cuts texts at
496
+ * its limit, as `embed` does).
376
497
  * @param {string} text
377
498
  * @param {boolean} add_special_tokens
378
499
  * @returns {Uint32Array}
@@ -388,6 +509,29 @@ export class WasmModel {
388
509
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
389
510
  return v2;
390
511
  }
512
+ /**
513
+ * Transcribes speech with a speech recognition model (Whisper).
514
+ * `audio` is mono PCM (`Float32Array`, at `sampleRate`, 16 kHz by
515
+ * default) or the bytes of a WAV file (`Uint8Array`; browsers decode
516
+ * other formats with `AudioContext` first). `options_json`:
517
+ * `{ language?: string, task?: "transcribe" | "translate",
518
+ * maxNewTokens?: number, sampleRate?: number }` (no language: detected).
519
+ * `on_text(text)` receives the text as it is generated and stops the
520
+ * transcription by returning `false` (or a promise resolving to
521
+ * `false`). Resolves to `{ text, language,
522
+ * duration, segments: [{ id, start, end, text, tokens }], tokens,
523
+ * stopped }`. Rejects with `UNSUPPORTED_TASK` on other models.
524
+ * @param {any} audio
525
+ * @param {string} options_json
526
+ * @param {Function | null} [on_text]
527
+ * @returns {Promise<any>}
528
+ */
529
+ transcribe(audio, options_json, on_text) {
530
+ const ptr0 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
531
+ const len0 = WASM_VECTOR_LEN;
532
+ const ret = wasm.wasmmodel_transcribe(this.__wbg_ptr, audio, ptr0, len0, isLikeNone(on_text) ? 0 : addToExternrefTable0(on_text));
533
+ return ret;
534
+ }
391
535
  }
392
536
  if (Symbol.dispose) WasmModel.prototype[Symbol.dispose] = WasmModel.prototype.free;
393
537
 
@@ -692,6 +836,18 @@ export function startThreadPool(threads) {
692
836
  return ret;
693
837
  }
694
838
 
839
+ /**
840
+ * `model_type` values of the encoders this build embeds with (models
841
+ * whose `WasmModel` answers `embed`).
842
+ * @returns {string[]}
843
+ */
844
+ export function supportedEncoderTypes() {
845
+ const ret = wasm.supportedEncoderTypes();
846
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
847
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
848
+ return v1;
849
+ }
850
+
695
851
  /**
696
852
  * `model_type` values (from `config.json`) of the architectures this build
697
853
  * can run.
@@ -704,6 +860,18 @@ export function supportedModelTypes() {
704
860
  return v1;
705
861
  }
706
862
 
863
+ /**
864
+ * `model_type` values of the speech recognition models this build runs
865
+ * (models whose `WasmModel` answers `transcribe`).
866
+ * @returns {string[]}
867
+ */
868
+ export function supportedSpeechTypes() {
869
+ const ret = wasm.supportedSpeechTypes();
870
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
871
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
872
+ return v1;
873
+ }
874
+
707
875
  /**
708
876
  * Version of the Rust engine, as declared in `Cargo.toml`.
709
877
  * @returns {string}
@@ -786,6 +954,11 @@ function __wbg_get_imports(memory) {
786
954
  const ret = arg0.WorkerGlobalScope;
787
955
  return ret;
788
956
  },
957
+ __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
958
+ const v = arg0;
959
+ const ret = typeof(v) === 'boolean' ? v : undefined;
960
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
961
+ },
789
962
  __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
790
963
  const ret = debugString(arg1);
791
964
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -985,6 +1158,16 @@ function __wbg_get_imports(memory) {
985
1158
  const ret = result;
986
1159
  return ret;
987
1160
  },
1161
+ __wbg_instanceof_Float32Array_31e80d3e88752523: function(arg0) {
1162
+ let result;
1163
+ try {
1164
+ result = arg0 instanceof Float32Array;
1165
+ } catch (_) {
1166
+ result = false;
1167
+ }
1168
+ const ret = result;
1169
+ return ret;
1170
+ },
988
1171
  __wbg_instanceof_GpuOutOfMemoryError_829d8185d83170f0: function(arg0) {
989
1172
  let result;
990
1173
  try {
@@ -1058,6 +1241,10 @@ function __wbg_get_imports(memory) {
1058
1241
  const ret = arg0.length;
1059
1242
  return ret;
1060
1243
  },
1244
+ __wbg_length_8768c6f6941913e3: function(arg0) {
1245
+ const ret = arg0.length;
1246
+ return ret;
1247
+ },
1061
1248
  __wbg_limits_f4203404018656d1: function(arg0) {
1062
1249
  const ret = arg0.limits;
1063
1250
  return ret;
@@ -1270,6 +1457,10 @@ function __wbg_get_imports(memory) {
1270
1457
  const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1271
1458
  return ret;
1272
1459
  },
1460
+ __wbg_new_from_slice_a500ec81601be48f: function(arg0, arg1) {
1461
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
1462
+ return ret;
1463
+ },
1273
1464
  __wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
1274
1465
  try {
1275
1466
  var state0 = {a: arg0, b: arg1};
@@ -1319,6 +1510,9 @@ function __wbg_get_imports(memory) {
1319
1510
  __wbg_postMessage_8105a302ed002474: function() { return handleError(function (arg0, arg1) {
1320
1511
  arg0.postMessage(arg1);
1321
1512
  }, arguments); },
1513
+ __wbg_prototypesetcall_804a1eb1b047ccb9: function(arg0, arg1, arg2) {
1514
+ Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), arg2);
1515
+ },
1322
1516
  __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
1323
1517
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1324
1518
  },
@@ -1348,6 +1542,10 @@ function __wbg_get_imports(memory) {
1348
1542
  const ret = arg0.reason;
1349
1543
  return (__wbindgen_enum_GpuDeviceLostReason.indexOf(ret) + 1 || 3) - 1;
1350
1544
  },
1545
+ __wbg_reject_bea6d825081bd4d7: function(arg0) {
1546
+ const ret = Promise.reject(arg0);
1547
+ return ret;
1548
+ },
1351
1549
  __wbg_requestAdapter_2cb1006baf7abd60: function(arg0) {
1352
1550
  const ret = arg0.requestAdapter();
1353
1551
  return ret;
@@ -1636,6 +1834,10 @@ function __wbg_get_imports(memory) {
1636
1834
  const ret = Atomics.waitAsync;
1637
1835
  return ret;
1638
1836
  },
1837
+ __wbg_wasmimagemodel_new: function(arg0) {
1838
+ const ret = WasmImageModel.__wrap(arg0);
1839
+ return ret;
1840
+ },
1639
1841
  __wbg_wasmmodel_new: function(arg0) {
1640
1842
  const ret = WasmModel.__wrap(arg0);
1641
1843
  return ret;
@@ -1644,43 +1846,43 @@ function __wbg_get_imports(memory) {
1644
1846
  arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
1645
1847
  }, arguments); },
1646
1848
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1647
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 392, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1849
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 440, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1648
1850
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true_);
1649
1851
  return ret;
1650
1852
  },
1651
1853
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
1652
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 932, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1854
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 991, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1653
1855
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue__core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_);
1654
1856
  return ret;
1655
1857
  },
1656
1858
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
1657
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 934, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1859
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 993, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1658
1860
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___futures__task__wait_async_polyfill__MessageEvent______true_);
1659
1861
  return ret;
1660
1862
  },
1661
1863
  __wbindgen_generic_0000000000000004: function(arg0, arg1) {
1662
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 390, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1864
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 438, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1663
1865
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_);
1664
1866
  return ret;
1665
1867
  },
1666
1868
  __wbindgen_generic_0000000000000005: function(arg0, arg1) {
1667
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 392, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1668
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__46);
1869
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 440, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1870
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__55);
1669
1871
  return ret;
1670
1872
  },
1671
1873
  __wbindgen_generic_0000000000000006: function(arg0, arg1) {
1672
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 392, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1673
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__47);
1874
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 440, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1875
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__56);
1674
1876
  return ret;
1675
1877
  },
1676
1878
  __wbindgen_generic_0000000000000007: function(arg0, arg1) {
1677
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 390, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1678
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__48);
1879
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 438, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1880
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__57);
1679
1881
  return ret;
1680
1882
  },
1681
1883
  __wbindgen_generic_0000000000000008: function(arg0, arg1) {
1682
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 390, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1683
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__49);
1884
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 438, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1885
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__58);
1684
1886
  return ret;
1685
1887
  },
1686
1888
  __wbindgen_generic_0000000000000009: function(arg0) {
@@ -1742,12 +1944,12 @@ function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b
1742
1944
  wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___futures__task__wait_async_polyfill__MessageEvent______true_(arg0, arg1, arg2);
1743
1945
  }
1744
1946
 
1745
- function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__46(arg0, arg1, arg2) {
1746
- wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__46(arg0, arg1, arg2);
1947
+ function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__55(arg0, arg1, arg2) {
1948
+ wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__55(arg0, arg1, arg2);
1747
1949
  }
1748
1950
 
1749
- function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__47(arg0, arg1, arg2) {
1750
- wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__47(arg0, arg1, arg2);
1951
+ function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__56(arg0, arg1, arg2) {
1952
+ wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__56(arg0, arg1, arg2);
1751
1953
  }
1752
1954
 
1753
1955
  function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue__core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_(arg0, arg1, arg2) {
@@ -1764,15 +1966,15 @@ function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bin
1764
1966
  }
1765
1967
  }
1766
1968
 
1767
- function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__48(arg0, arg1, arg2) {
1768
- const ret = wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__48(arg0, arg1, arg2);
1969
+ function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__57(arg0, arg1, arg2) {
1970
+ const ret = wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__57(arg0, arg1, arg2);
1769
1971
  if (ret[1]) {
1770
1972
  throw takeFromExternrefTable0(ret[0]);
1771
1973
  }
1772
1974
  }
1773
1975
 
1774
- function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__49(arg0, arg1, arg2) {
1775
- const ret = wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__49(arg0, arg1, arg2);
1976
+ function wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__58(arg0, arg1, arg2) {
1977
+ const ret = wasm.wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__58(arg0, arg1, arg2);
1776
1978
  if (ret[1]) {
1777
1979
  throw takeFromExternrefTable0(ret[0]);
1778
1980
  }
@@ -1820,6 +2022,9 @@ const JsWeightCacheFinalization = (typeof FinalizationRegistry === 'undefined')
1820
2022
  const Sha256HasherFinalization = (typeof FinalizationRegistry === 'undefined')
1821
2023
  ? { register: () => {}, unregister: () => {} }
1822
2024
  : new FinalizationRegistry(ptr => wasm.__wbg_sha256hasher_free(ptr, 1));
2025
+ const WasmImageModelFinalization = (typeof FinalizationRegistry === 'undefined')
2026
+ ? { register: () => {}, unregister: () => {} }
2027
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmimagemodel_free(ptr, 1));
1823
2028
  const WasmModelFinalization = (typeof FinalizationRegistry === 'undefined')
1824
2029
  ? { register: () => {}, unregister: () => {} }
1825
2030
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmmodel_free(ptr, 1));
Binary file