@phenx-inc/ctlsurf 0.8.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 (38) hide show
  1. package/out/headless/index.mjs +339 -2
  2. package/out/headless/index.mjs.map +4 -4
  3. package/out/main/index.js +441 -20
  4. package/out/preload/index.js +9 -0
  5. package/out/renderer/assets/{cssMode-BQN8v2ok.js → cssMode-BbCVOTaJ.js} +3 -3
  6. package/out/renderer/assets/{freemarker2-DbxGYYVp.js → freemarker2-DryLywQv.js} +1 -1
  7. package/out/renderer/assets/{handlebars-3auU1CAd.js → handlebars-CdUMtSdr.js} +1 -1
  8. package/out/renderer/assets/{html-D8xFiRmI.js → html-Cwkf2GMH.js} +1 -1
  9. package/out/renderer/assets/{htmlMode-M3MApZ4n.js → htmlMode-C7PzhXxH.js} +3 -3
  10. package/out/renderer/assets/{index-B-iM7dFC.css → index-BIceGcz3.css} +52 -0
  11. package/out/renderer/assets/{index---H6cxNl.js → index-Dg1vMspf.js} +274 -244
  12. package/out/renderer/assets/{javascript-BO_ViZM5.js → javascript-Cy7ROXJl.js} +2 -2
  13. package/out/renderer/assets/{jsonMode-CKp2zvZu.js → jsonMode-BtZtt3QW.js} +3 -3
  14. package/out/renderer/assets/{liquid-C1eHcrht.js → liquid-xReAQeYs.js} +1 -1
  15. package/out/renderer/assets/{lspLanguageFeatures-CHWJx_Tl.js → lspLanguageFeatures-Dmx0L0Bw.js} +1 -1
  16. package/out/renderer/assets/{mdx-Qqdtk7fL.js → mdx-YMNFO1Zz.js} +1 -1
  17. package/out/renderer/assets/{python-DKu7rNbs.js → python-BExaDVxv.js} +1 -1
  18. package/out/renderer/assets/{razor-BOMpCo6z.js → razor-HL8ANmQ4.js} +1 -1
  19. package/out/renderer/assets/{transformers.web-DtSCnG36.js → transformers.web-_PuZoIho.js} +824 -19
  20. package/out/renderer/assets/{tsMode-yAjlPR-D.js → tsMode-Dqd8vdLE.js} +1 -1
  21. package/out/renderer/assets/{typescript-BiJRCUcL.js → typescript-Dysz1PTX.js} +1 -1
  22. package/out/renderer/assets/{xml-D4PvYeQq.js → xml-BHp5Z9nc.js} +1 -1
  23. package/out/renderer/assets/{yaml-BeHVkmnS.js → yaml-CPDHxVup.js} +1 -1
  24. package/out/renderer/index.html +64 -2
  25. package/out/repro-toggle.mjs +305 -0
  26. package/package.json +1 -1
  27. package/src/main/agentState.ts +329 -0
  28. package/src/main/index.ts +107 -19
  29. package/src/main/orchestrator.ts +34 -2
  30. package/src/main/transcripts.ts +134 -0
  31. package/src/preload/index.ts +11 -0
  32. package/src/renderer/App.tsx +48 -13
  33. package/src/renderer/components/FloatingMic.tsx +48 -0
  34. package/src/renderer/components/VoiceInput.tsx +36 -149
  35. package/src/renderer/index.html +62 -0
  36. package/src/renderer/lib/localWhisper.ts +46 -2
  37. package/src/renderer/lib/speech.ts +18 -0
  38. package/src/renderer/styles.css +52 -0
@@ -11256,6 +11256,23 @@ function log_softmax(arr) {
11256
11256
  logSoftmaxArr
11257
11257
  );
11258
11258
  }
11259
+ function dot(arr1, arr2) {
11260
+ let result = 0;
11261
+ for (let i = 0; i < arr1.length; ++i) {
11262
+ result += arr1[i] * arr2[i];
11263
+ }
11264
+ return result;
11265
+ }
11266
+ function cos_sim(arr1, arr2) {
11267
+ const dotProduct = dot(arr1, arr2);
11268
+ const magnitudeA = magnitude(arr1);
11269
+ const magnitudeB = magnitude(arr2);
11270
+ const cosineSimilarity = dotProduct / (magnitudeA * magnitudeB);
11271
+ return cosineSimilarity;
11272
+ }
11273
+ function magnitude(arr) {
11274
+ return Math.sqrt(arr.reduce((acc, val) => acc + val * val, 0));
11275
+ }
11259
11276
  function min2(arr) {
11260
11277
  if (arr.length === 0) throw Error("Array must not be empty");
11261
11278
  let min3 = arr[0];
@@ -14234,6 +14251,10 @@ async function matmul(a, b) {
14234
14251
  const op = await TensorOpRegistry.matmul;
14235
14252
  return await op({ a, b });
14236
14253
  }
14254
+ async function rfft(x, a) {
14255
+ const op = await TensorOpRegistry.rfft;
14256
+ return await op({ x, a });
14257
+ }
14237
14258
  async function topk(x, k2) {
14238
14259
  const op = await TensorOpRegistry.top_k;
14239
14260
  if (k2 == null) {
@@ -14254,7 +14275,7 @@ async function slice2(data, starts, ends, axes, steps) {
14254
14275
  s: arrayToIndexTensor(starts),
14255
14276
  e: arrayToIndexTensor(ends),
14256
14277
  a: arrayToIndexTensor(axes),
14257
- t: arrayToIndexTensor(new Array(axes.length).fill(1))
14278
+ t: arrayToIndexTensor(steps ?? new Array(axes.length).fill(1))
14258
14279
  });
14259
14280
  }
14260
14281
  function mean_pooling(last_hidden_state, attention_mask) {
@@ -14282,6 +14303,37 @@ function mean_pooling(last_hidden_state, attention_mask) {
14282
14303
  }
14283
14304
  return new Tensor22(last_hidden_state.type, returnedData, shape);
14284
14305
  }
14306
+ function layer_norm(input, normalized_shape, { eps = 1e-5 } = {}) {
14307
+ if (input.dims.length !== 2) {
14308
+ throw new Error("`layer_norm` currently only supports 2D input.");
14309
+ }
14310
+ const [batchSize, featureDim] = input.dims;
14311
+ if (normalized_shape.length !== 1 && normalized_shape[0] !== featureDim) {
14312
+ throw new Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");
14313
+ }
14314
+ const [std, mean2] = std_mean(input, 1, 0, true);
14315
+ const stdData = (
14316
+ /** @type {Float32Array} */
14317
+ std.data
14318
+ );
14319
+ const meanData = (
14320
+ /** @type {Float32Array} */
14321
+ mean2.data
14322
+ );
14323
+ const inputData = (
14324
+ /** @type {Float32Array} */
14325
+ input.data
14326
+ );
14327
+ const returnedData = new inputData.constructor(inputData.length);
14328
+ for (let i = 0; i < batchSize; ++i) {
14329
+ const offset = i * featureDim;
14330
+ for (let j = 0; j < featureDim; ++j) {
14331
+ const offset2 = offset + j;
14332
+ returnedData[offset2] = (inputData[offset2] - meanData[i]) / (stdData[i] + eps);
14333
+ }
14334
+ }
14335
+ return new Tensor22(input.type, returnedData, input.dims);
14336
+ }
14285
14337
  function calc_squeeze_dims(dims, dim) {
14286
14338
  dims = dims.slice();
14287
14339
  if (dim === null) {
@@ -14497,6 +14549,14 @@ function zeros(size) {
14497
14549
  function zeros_like(tensor) {
14498
14550
  return zeros(tensor.dims);
14499
14551
  }
14552
+ function rand(size) {
14553
+ const length = size.reduce((a, b) => a * b, 1);
14554
+ return new Tensor22(
14555
+ "float32",
14556
+ Float32Array.from({ length }, () => random.random()),
14557
+ size
14558
+ );
14559
+ }
14500
14560
  function randn(size) {
14501
14561
  const length = size.reduce((a, b) => a * b, 1);
14502
14562
  return new Tensor22(
@@ -18627,7 +18687,7 @@ var RawImage = class _RawImage {
18627
18687
  });
18628
18688
  }
18629
18689
  };
18630
- RawImage.read.bind(RawImage);
18690
+ var load_image = RawImage.read.bind(RawImage);
18631
18691
  function constraint_to_multiple_of(val, multiple, minVal = 0, maxVal = null) {
18632
18692
  const a = val / multiple;
18633
18693
  let x = bankers_round(a) * multiple;
@@ -23245,6 +23305,45 @@ var TemperatureLogitsWarper = class extends LogitsWarper {
23245
23305
  return logits;
23246
23306
  }
23247
23307
  };
23308
+ var TopPLogitsWarper = class extends LogitsWarper {
23309
+ /**
23310
+ * Create a `TopPLogitsWarper`.
23311
+ * @param {number} top_p If set to < 1, only the smallest set of most probable tokens with
23312
+ * probabilities that add up to `top_p` or higher are kept for generation.
23313
+ * @param {Object} options Additional options for the top-p sampling.
23314
+ * @param {number} [options.filter_value=-Infinity] All filtered values will be set to this float value.
23315
+ * @param {number} [options.min_tokens_to_keep=1] Minimum number of tokens that cannot be filtered.
23316
+ */
23317
+ constructor(top_p, { filter_value = -Infinity, min_tokens_to_keep = 1 } = {}) {
23318
+ super();
23319
+ if (top_p < 0 || top_p > 1) {
23320
+ throw new Error(`\`top_p\` must be a float > 0 and < 1, but is ${top_p}`);
23321
+ }
23322
+ if (!Number.isInteger(min_tokens_to_keep) || min_tokens_to_keep < 1) {
23323
+ throw new Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${min_tokens_to_keep}`);
23324
+ }
23325
+ this.top_p = top_p;
23326
+ this.filter_value = filter_value;
23327
+ this.min_tokens_to_keep = min_tokens_to_keep;
23328
+ }
23329
+ };
23330
+ var TopKLogitsWarper = class extends LogitsWarper {
23331
+ /**
23332
+ * Create a `TopKLogitsWarper`.
23333
+ * @param {number} top_k If set to > 0, only the top `top_k` tokens are kept for generation.
23334
+ * @param {Object} options Additional options for the top-k sampling.
23335
+ * @param {number} [options.filter_value=-Infinity] All filtered values will be set to this float value.
23336
+ * @param {number} [options.min_tokens_to_keep=1] Minimum number of tokens that cannot be filtered.
23337
+ */
23338
+ constructor(top_k, { filter_value = -Infinity, min_tokens_to_keep = 1 } = {}) {
23339
+ super();
23340
+ if (!Number.isInteger(top_k) || top_k < 0) {
23341
+ throw new Error(`\`top_k\` must be a positive integer, but is ${top_k}`);
23342
+ }
23343
+ this.top_k = Math.max(top_k, min_tokens_to_keep);
23344
+ this.filter_value = filter_value;
23345
+ }
23346
+ };
23248
23347
  var GenerationConfig = class {
23249
23348
  // Parameters that control the length of the output
23250
23349
  /**
@@ -23674,6 +23773,21 @@ var EosTokenCriteria = class extends StoppingCriteria {
23674
23773
  });
23675
23774
  }
23676
23775
  };
23776
+ var InterruptableStoppingCriteria = class extends StoppingCriteria {
23777
+ constructor() {
23778
+ super();
23779
+ this.interrupted = false;
23780
+ }
23781
+ interrupt() {
23782
+ this.interrupted = true;
23783
+ }
23784
+ reset() {
23785
+ this.interrupted = false;
23786
+ }
23787
+ _call(input_ids, scores) {
23788
+ return new Array(input_ids.length).fill(this.interrupted);
23789
+ }
23790
+ };
23677
23791
  var LogitsSampler = class extends Callable {
23678
23792
  /**
23679
23793
  * Creates a new Sampler object with the specified generation config.
@@ -31064,48 +31178,48 @@ var AutoModelForObjectDetection = class extends PretrainedMixin {
31064
31178
  var AutoModelForZeroShotObjectDetection = class extends PretrainedMixin {
31065
31179
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES];
31066
31180
  };
31067
- (class extends PretrainedMixin {
31181
+ var AutoModelForMaskGeneration = class extends PretrainedMixin {
31068
31182
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES];
31069
- });
31183
+ };
31070
31184
  var AutoModelForCTC = class extends PretrainedMixin {
31071
31185
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_CTC_MAPPING_NAMES];
31072
31186
  };
31073
31187
  var AutoModelForAudioClassification = class extends PretrainedMixin {
31074
31188
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES];
31075
31189
  };
31076
- (class extends PretrainedMixin {
31190
+ var AutoModelForXVector = class extends PretrainedMixin {
31077
31191
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES];
31078
- });
31079
- (class extends PretrainedMixin {
31192
+ };
31193
+ var AutoModelForAudioFrameClassification = class extends PretrainedMixin {
31080
31194
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES];
31081
- });
31195
+ };
31082
31196
  var AutoModelForDocumentQuestionAnswering = class extends PretrainedMixin {
31083
31197
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES];
31084
31198
  };
31085
- (class extends PretrainedMixin {
31199
+ var AutoModelForImageMatting = class extends PretrainedMixin {
31086
31200
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES];
31087
- });
31201
+ };
31088
31202
  var AutoModelForImageToImage = class extends PretrainedMixin {
31089
31203
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES];
31090
31204
  };
31091
31205
  var AutoModelForDepthEstimation = class extends PretrainedMixin {
31092
31206
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES];
31093
31207
  };
31094
- (class extends PretrainedMixin {
31208
+ var AutoModelForNormalEstimation = class extends PretrainedMixin {
31095
31209
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES];
31096
- });
31097
- (class extends PretrainedMixin {
31210
+ };
31211
+ var AutoModelForPoseEstimation = class extends PretrainedMixin {
31098
31212
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES];
31099
- });
31213
+ };
31100
31214
  var AutoModelForImageFeatureExtraction = class extends PretrainedMixin {
31101
31215
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES];
31102
31216
  };
31103
- (class extends PretrainedMixin {
31217
+ var AutoModelForImageTextToText = class extends PretrainedMixin {
31104
31218
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES];
31105
- });
31106
- (class extends PretrainedMixin {
31219
+ };
31220
+ var AutoModelForAudioTextToText = class extends PretrainedMixin {
31107
31221
  static MODEL_CLASS_MAPPINGS = [MODEL_MAPPINGS.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES];
31108
- });
31222
+ };
31109
31223
  async function prepareImages(images) {
31110
31224
  if (!Array.isArray(images)) {
31111
31225
  images = [images];
@@ -32752,7 +32866,674 @@ async function pipeline2(task, model = null, {
32752
32866
  const pipelineClass = pipelineInfo.pipeline;
32753
32867
  return new pipelineClass(results);
32754
32868
  }
32755
- apis.IS_PROCESS_AVAILABLE ? (x) => process.stdout.write(x) : (x) => console.log(x);
32869
+ var is_chinese_char2 = (cp) => cp >= 19968 && cp <= 40959 || cp >= 13312 && cp <= 19903 || cp >= 131072 && cp <= 173791 || cp >= 173824 && cp <= 177983 || cp >= 177984 && cp <= 178207 || cp >= 178208 && cp <= 183983 || cp >= 63744 && cp <= 64255 || cp >= 194560 && cp <= 195103;
32870
+ var BaseStreamer = class {
32871
+ /**
32872
+ * Function that is called by `.generate()` to push new tokens
32873
+ * @param {bigint[][]} value
32874
+ */
32875
+ put(value) {
32876
+ throw Error("Not implemented");
32877
+ }
32878
+ /**
32879
+ * Function that is called by `.generate()` to signal the end of generation
32880
+ */
32881
+ end() {
32882
+ throw Error("Not implemented");
32883
+ }
32884
+ };
32885
+ var stdout_write = apis.IS_PROCESS_AVAILABLE ? (x) => process.stdout.write(x) : (x) => console.log(x);
32886
+ var TextStreamer = class extends BaseStreamer {
32887
+ /**
32888
+ *
32889
+ * @param {import('../tokenization_utils.js').PreTrainedTokenizer} tokenizer
32890
+ * @param {Object} options
32891
+ * @param {boolean} [options.skip_prompt=false] Whether to skip the prompt tokens
32892
+ * @param {boolean} [options.skip_special_tokens=true] Whether to skip special tokens when decoding
32893
+ * @param {function(string): void} [options.callback_function=null] Function to call when a piece of text is ready to display
32894
+ * @param {function(bigint[]): void} [options.token_callback_function=null] Function to call when a new token is generated
32895
+ * @param {Object} [options.decode_kwargs={}] Additional keyword arguments to pass to the tokenizer's decode method
32896
+ */
32897
+ constructor(tokenizer, {
32898
+ skip_prompt = false,
32899
+ callback_function = null,
32900
+ token_callback_function = null,
32901
+ skip_special_tokens = true,
32902
+ decode_kwargs = {},
32903
+ ...kwargs
32904
+ } = {}) {
32905
+ super();
32906
+ this.tokenizer = tokenizer;
32907
+ this.skip_prompt = skip_prompt;
32908
+ this.callback_function = callback_function ?? stdout_write;
32909
+ this.token_callback_function = token_callback_function;
32910
+ this.decode_kwargs = { skip_special_tokens, ...decode_kwargs, ...kwargs };
32911
+ this.token_cache = [];
32912
+ this.print_len = 0;
32913
+ this.next_tokens_are_prompt = true;
32914
+ this.special_ids = new Set(this.tokenizer.all_special_ids.map(BigInt));
32915
+ }
32916
+ /**
32917
+ * Receives tokens, decodes them, and prints them to stdout as soon as they form entire words.
32918
+ * @param {bigint[][]} value
32919
+ */
32920
+ put(value) {
32921
+ if (value.length > 1) {
32922
+ throw Error("TextStreamer only supports batch size of 1");
32923
+ }
32924
+ const is_prompt = this.next_tokens_are_prompt;
32925
+ if (is_prompt) {
32926
+ this.next_tokens_are_prompt = false;
32927
+ if (this.skip_prompt) return;
32928
+ }
32929
+ const tokens = value[0];
32930
+ this.token_callback_function?.(tokens);
32931
+ if (tokens.length === 1 && this.special_ids.has(tokens[0])) {
32932
+ if (this.decode_kwargs.skip_special_tokens) return;
32933
+ if (this.token_cache.length > 0) {
32934
+ const text2 = this.tokenizer.decode(this.token_cache, this.decode_kwargs);
32935
+ const printable_text2 = text2.slice(this.print_len);
32936
+ this.on_finalized_text(printable_text2, false);
32937
+ this.token_cache = [];
32938
+ this.print_len = 0;
32939
+ }
32940
+ const special_text = this.tokenizer.decode(tokens, this.decode_kwargs);
32941
+ this.on_finalized_text(special_text, false);
32942
+ return;
32943
+ }
32944
+ this.token_cache = mergeArrays(this.token_cache, tokens);
32945
+ const text = this.tokenizer.decode(this.token_cache, this.decode_kwargs);
32946
+ let printable_text;
32947
+ if (is_prompt || text.endsWith("\n")) {
32948
+ printable_text = text.slice(this.print_len);
32949
+ this.token_cache = [];
32950
+ this.print_len = 0;
32951
+ } else if (text.length > 0 && is_chinese_char2(text.charCodeAt(text.length - 1))) {
32952
+ printable_text = text.slice(this.print_len);
32953
+ this.print_len += printable_text.length;
32954
+ } else {
32955
+ printable_text = text.slice(this.print_len, text.lastIndexOf(" ") + 1);
32956
+ this.print_len += printable_text.length;
32957
+ }
32958
+ this.on_finalized_text(printable_text, false);
32959
+ }
32960
+ /**
32961
+ * Flushes any remaining cache and prints a newline to stdout.
32962
+ */
32963
+ end() {
32964
+ let printable_text;
32965
+ if (this.token_cache.length > 0) {
32966
+ const text = this.tokenizer.decode(this.token_cache, this.decode_kwargs);
32967
+ printable_text = text.slice(this.print_len);
32968
+ this.token_cache = [];
32969
+ this.print_len = 0;
32970
+ } else {
32971
+ printable_text = "";
32972
+ }
32973
+ this.next_tokens_are_prompt = true;
32974
+ this.on_finalized_text(printable_text, true);
32975
+ }
32976
+ /**
32977
+ * Prints the new text to stdout. If the stream is ending, also prints a newline.
32978
+ * @param {string} text
32979
+ * @param {boolean} stream_end
32980
+ */
32981
+ on_finalized_text(text, stream_end) {
32982
+ if (text.length > 0) {
32983
+ this.callback_function?.(text);
32984
+ }
32985
+ if (stream_end && this.callback_function === stdout_write && apis.IS_PROCESS_AVAILABLE) {
32986
+ this.callback_function?.("\n");
32987
+ }
32988
+ }
32989
+ };
32990
+ var WhisperTextStreamer = class extends TextStreamer {
32991
+ /**
32992
+ * @param {import('../models/whisper/tokenization_whisper.js').WhisperTokenizer} tokenizer
32993
+ * @param {Object} options
32994
+ * @param {boolean} [options.skip_prompt=false] Whether to skip the prompt tokens
32995
+ * @param {function(string): void} [options.callback_function=null] Function to call when a piece of text is ready to display
32996
+ * @param {function(bigint[]): void} [options.token_callback_function=null] Function to call when a new token is generated
32997
+ * @param {function(number): void} [options.on_chunk_start=null] Function to call when a new chunk starts
32998
+ * @param {function(number): void} [options.on_chunk_end=null] Function to call when a chunk ends
32999
+ * @param {function(): void} [options.on_finalize=null] Function to call when the stream is finalized
33000
+ * @param {number} [options.time_precision=0.02] Precision of the timestamps
33001
+ * @param {boolean} [options.skip_special_tokens=true] Whether to skip special tokens when decoding
33002
+ * @param {Object} [options.decode_kwargs={}] Additional keyword arguments to pass to the tokenizer's decode method
33003
+ */
33004
+ constructor(tokenizer, {
33005
+ skip_prompt = false,
33006
+ callback_function = null,
33007
+ token_callback_function = null,
33008
+ on_chunk_start = null,
33009
+ on_chunk_end = null,
33010
+ on_finalize = null,
33011
+ time_precision = 0.02,
33012
+ skip_special_tokens = true,
33013
+ decode_kwargs = {}
33014
+ } = {}) {
33015
+ super(tokenizer, {
33016
+ skip_prompt,
33017
+ skip_special_tokens,
33018
+ callback_function,
33019
+ token_callback_function,
33020
+ decode_kwargs
33021
+ });
33022
+ this.timestamp_begin = tokenizer.timestamp_begin;
33023
+ this.on_chunk_start = on_chunk_start;
33024
+ this.on_chunk_end = on_chunk_end;
33025
+ this.on_finalize = on_finalize;
33026
+ this.time_precision = time_precision;
33027
+ this.waiting_for_timestamp = false;
33028
+ }
33029
+ /**
33030
+ * @param {bigint[][]} value
33031
+ */
33032
+ put(value) {
33033
+ if (value.length > 1) {
33034
+ throw Error("WhisperTextStreamer only supports batch size of 1");
33035
+ }
33036
+ const tokens = value[0];
33037
+ if (tokens.length === 1) {
33038
+ const offset = Number(tokens[0]) - this.timestamp_begin;
33039
+ if (offset >= 0) {
33040
+ const time = offset * this.time_precision;
33041
+ if (this.waiting_for_timestamp) {
33042
+ this.on_chunk_end?.(time);
33043
+ } else {
33044
+ this.on_chunk_start?.(time);
33045
+ }
33046
+ this.waiting_for_timestamp = !this.waiting_for_timestamp;
33047
+ this.token_callback_function?.(tokens);
33048
+ return;
33049
+ }
33050
+ }
33051
+ return super.put(value);
33052
+ }
33053
+ end() {
33054
+ super.end();
33055
+ this.on_finalize?.();
33056
+ }
33057
+ };
33058
+ var RawVideoFrame = class {
33059
+ /**
33060
+ * @param {RawImage} image
33061
+ * @param {number} timestamp
33062
+ */
33063
+ constructor(image, timestamp) {
33064
+ this.image = image;
33065
+ this.timestamp = timestamp;
33066
+ }
33067
+ };
33068
+ var RawVideo = class {
33069
+ /**
33070
+ * @param {RawVideoFrame[]|RawImage[]} frames
33071
+ * @param {number} duration
33072
+ */
33073
+ constructor(frames, duration) {
33074
+ if (frames.length > 0 && frames[0] instanceof RawImage) {
33075
+ frames = frames.map((image, i) => new RawVideoFrame(image, (i + 1) / (frames.length + 1) * duration));
33076
+ }
33077
+ this.frames = /** @type {RawVideoFrame[]} */
33078
+ frames;
33079
+ this.duration = duration;
33080
+ }
33081
+ get width() {
33082
+ return this.frames[0].image.width;
33083
+ }
33084
+ get height() {
33085
+ return this.frames[0].image.height;
33086
+ }
33087
+ get fps() {
33088
+ return this.frames.length / this.duration;
33089
+ }
33090
+ };
33091
+ async function load_video(src, { num_frames = null, fps = null } = {}) {
33092
+ if (!apis.IS_BROWSER_ENV) {
33093
+ throw new Error("`load_video` is currently only supported in browser environments.");
33094
+ }
33095
+ if (num_frames == null && fps == null) {
33096
+ throw new Error("Either num_frames or fps must be provided.");
33097
+ }
33098
+ const frames = [];
33099
+ const video = document.createElement("video");
33100
+ video.crossOrigin = "anonymous";
33101
+ video.muted = true;
33102
+ if (typeof src === "string") {
33103
+ video.src = src;
33104
+ } else if (src instanceof Blob) {
33105
+ video.src = URL.createObjectURL(src);
33106
+ } else if (src instanceof HTMLVideoElement) {
33107
+ video.src = src.src;
33108
+ } else {
33109
+ throw new Error("Invalid URL or video element provided.");
33110
+ }
33111
+ await new Promise((resolve) => video.onloadedmetadata = resolve);
33112
+ if (video.seekable.start(0) === video.seekable.end(0)) {
33113
+ const response = await env.fetch(video.src);
33114
+ const blob = await response.blob();
33115
+ video.src = URL.createObjectURL(blob);
33116
+ await new Promise((resolve) => video.onloadedmetadata = resolve);
33117
+ }
33118
+ const duration = video.duration;
33119
+ let count2, step;
33120
+ if (num_frames != null) {
33121
+ count2 = num_frames;
33122
+ step = num_frames === 1 ? 0 : duration / (num_frames - 1);
33123
+ } else {
33124
+ step = 1 / fps;
33125
+ count2 = Math.floor(duration / step);
33126
+ }
33127
+ let sampleTimes = [];
33128
+ for (let i = 0; i < count2; ++i) {
33129
+ sampleTimes.push(num_frames === 1 ? duration / 2 : i * step);
33130
+ }
33131
+ const canvas = document.createElement("canvas");
33132
+ canvas.width = video.videoWidth;
33133
+ canvas.height = video.videoHeight;
33134
+ const ctx = canvas.getContext("2d", { willReadFrequently: true });
33135
+ for (const t of sampleTimes) {
33136
+ video.currentTime = t;
33137
+ await new Promise((resolve) => {
33138
+ video.onseeked = resolve;
33139
+ });
33140
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
33141
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
33142
+ const frameData = new RawImage(imageData.data, canvas.width, canvas.height, 4);
33143
+ const frame = new RawVideoFrame(frameData, t);
33144
+ frames.push(frame);
33145
+ }
33146
+ video.remove();
33147
+ return new RawVideo(frames, duration);
33148
+ }
33149
+ async function check_files_cache(modelId, files, options = {}) {
33150
+ const cache2 = await getCache(options?.cache_dir);
33151
+ if (!cache2) {
33152
+ const fileStatuses2 = files.map((filename) => ({ file: filename, cached: false }));
33153
+ return { allCached: false, files: fileStatuses2 };
33154
+ }
33155
+ const fileStatuses = await Promise.all(
33156
+ files.map(async (filename) => {
33157
+ const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache2);
33158
+ const cached = await checkCachedResource(cache2, localPath, proposedCacheKey);
33159
+ return { file: filename, cached: !!cached };
33160
+ })
33161
+ );
33162
+ return { allCached: fileStatuses.every((f) => f.cached), files: fileStatuses };
33163
+ }
33164
+ async function is_file_cached(modelId, filename, options = {}) {
33165
+ const cache2 = await getCache(options?.cache_dir);
33166
+ if (!cache2) return false;
33167
+ const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache2);
33168
+ return !!await checkCachedResource(cache2, localPath, proposedCacheKey);
33169
+ }
33170
+ async function is_cached(modelId, options = {}) {
33171
+ if (!modelId) {
33172
+ throw new Error("modelId is required");
33173
+ }
33174
+ if (!await is_file_cached(modelId, "config.json", options)) {
33175
+ return false;
33176
+ }
33177
+ const files = await get_files(modelId, options);
33178
+ const result = await check_files_cache(modelId, files, options);
33179
+ return result.allCached;
33180
+ }
33181
+ async function is_cached_files(modelId, options = {}) {
33182
+ if (!modelId) {
33183
+ throw new Error("modelId is required");
33184
+ }
33185
+ const files = await get_files(modelId, options);
33186
+ return await check_files_cache(modelId, files, options);
33187
+ }
33188
+ async function is_pipeline_cached(task, modelId, options = {}) {
33189
+ if (!task) {
33190
+ throw new Error("task is required");
33191
+ }
33192
+ if (!modelId) {
33193
+ throw new Error("modelId is required");
33194
+ }
33195
+ if (!await is_file_cached(modelId, "config.json", options)) {
33196
+ return false;
33197
+ }
33198
+ const files = await get_pipeline_files(task, modelId, options);
33199
+ const result = await check_files_cache(modelId, files, options);
33200
+ return result.allCached;
33201
+ }
33202
+ async function is_pipeline_cached_files(task, modelId, options = {}) {
33203
+ if (!task) {
33204
+ throw new Error("task is required");
33205
+ }
33206
+ if (!modelId) {
33207
+ throw new Error("modelId is required");
33208
+ }
33209
+ const files = await get_pipeline_files(task, modelId, options);
33210
+ return await check_files_cache(modelId, files, options);
33211
+ }
33212
+ async function clear_files_from_cache(modelId, files, options = {}) {
33213
+ const cache2 = await getCache(options?.cache_dir);
33214
+ if (!cache2) {
33215
+ return {
33216
+ filesDeleted: 0,
33217
+ filesCached: 0,
33218
+ files: files.map((filename) => ({ file: filename, deleted: false, wasCached: false }))
33219
+ };
33220
+ }
33221
+ if (!cache2.delete) {
33222
+ throw new Error("Cache does not support delete operation");
33223
+ }
33224
+ const results = await Promise.all(
33225
+ files.map(async (filename) => {
33226
+ const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache2);
33227
+ const cached = await checkCachedResource(cache2, localPath, proposedCacheKey);
33228
+ const wasCached = !!cached;
33229
+ let deleted = false;
33230
+ if (wasCached) {
33231
+ const deletedWithProposed = await cache2.delete(proposedCacheKey);
33232
+ const deletedWithLocal = !deletedWithProposed && proposedCacheKey !== localPath ? await cache2.delete(localPath) : false;
33233
+ deleted = deletedWithProposed || deletedWithLocal;
33234
+ }
33235
+ return { file: filename, deleted, wasCached };
33236
+ })
33237
+ );
33238
+ return {
33239
+ filesDeleted: results.filter((r) => r.deleted).length,
33240
+ filesCached: results.filter((r) => r.wasCached).length,
33241
+ files: results
33242
+ };
33243
+ }
33244
+ async function clear_cache(modelId, options = {}) {
33245
+ if (!modelId) {
33246
+ throw new Error("modelId is required");
33247
+ }
33248
+ const files = await get_files(modelId, options);
33249
+ return await clear_files_from_cache(modelId, files, options);
33250
+ }
33251
+ async function clear_pipeline_cache(task, modelId, options = {}) {
33252
+ if (!task) {
33253
+ throw new Error("task is required");
33254
+ }
33255
+ if (!modelId) {
33256
+ throw new Error("modelId is required");
33257
+ }
33258
+ const files = await get_pipeline_files(task, modelId, options);
33259
+ return await clear_files_from_cache(modelId, files, options);
33260
+ }
33261
+ var CONCRETE_DTYPES = Object.keys(DEFAULT_DTYPE_SUFFIX_MAPPING);
33262
+ async function get_available_dtypes(modelId, { config = null, model_file_name = null, revision = "main", cache_dir = null, local_files_only = false } = {}) {
33263
+ config = await get_config(modelId, { config, cache_dir, local_files_only, revision });
33264
+ const subfolder = "onnx";
33265
+ const modelType = resolve_model_type(config);
33266
+ const { sessions } = getSessionsConfig(modelType, config, { model_file_name });
33267
+ const baseNames = Object.values(sessions);
33268
+ const metadataOptions = { revision, cache_dir, local_files_only };
33269
+ const probeResults = await Promise.all(
33270
+ CONCRETE_DTYPES.map(async (dtype) => {
33271
+ const suffix = DEFAULT_DTYPE_SUFFIX_MAPPING[dtype] ?? "";
33272
+ const allExist = await Promise.all(
33273
+ baseNames.map(async (baseName) => {
33274
+ const filename = `${subfolder}/${baseName}${suffix}.onnx`;
33275
+ const metadata = await get_file_metadata(modelId, filename, metadataOptions);
33276
+ return metadata.exists;
33277
+ })
33278
+ );
33279
+ return { dtype, available: allExist.every(Boolean) };
33280
+ })
33281
+ );
33282
+ return probeResults.filter((r) => r.available).map((r) => r.dtype);
33283
+ }
33284
+ var ModelRegistry = class {
33285
+ /**
33286
+ * Get all files (model, tokenizer, processor) needed for a model.
33287
+ *
33288
+ * @param {string} modelId - The model id (e.g., "onnx-community/bert-base-uncased-ONNX")
33289
+ * @param {Object} [options] - Optional parameters
33290
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
33291
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
33292
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
33293
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
33294
+ * @param {boolean} [options.include_tokenizer=true] - Whether to check for tokenizer files
33295
+ * @param {boolean} [options.include_processor=true] - Whether to check for processor files
33296
+ * @returns {Promise<string[]>} Array of file paths
33297
+ *
33298
+ * @example
33299
+ * const files = await ModelRegistry.get_files('onnx-community/gpt2-ONNX');
33300
+ * console.log(files); // ['config.json', 'tokenizer.json', 'onnx/model_q4.onnx', ...]
33301
+ */
33302
+ static async get_files(modelId, options = {}) {
33303
+ return get_files(modelId, options);
33304
+ }
33305
+ /**
33306
+ * Get all files needed for a specific pipeline task.
33307
+ * Automatically determines which components are needed based on the task.
33308
+ *
33309
+ * @param {string} task - The pipeline task (e.g., "text-generation", "background-removal")
33310
+ * @param {string} modelId - The model id (e.g., "onnx-community/bert-base-uncased-ONNX")
33311
+ * @param {Object} [options] - Optional parameters
33312
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
33313
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
33314
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
33315
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
33316
+ * @returns {Promise<string[]>} Array of file paths
33317
+ *
33318
+ * @example
33319
+ * const files = await ModelRegistry.get_pipeline_files('text-generation', 'onnx-community/gpt2-ONNX');
33320
+ * console.log(files); // ['config.json', 'tokenizer.json', 'onnx/model_q4.onnx', ...]
33321
+ */
33322
+ static async get_pipeline_files(task, modelId, options = {}) {
33323
+ return get_pipeline_files(task, modelId, options);
33324
+ }
33325
+ /**
33326
+ * Get model files needed for a specific model.
33327
+ *
33328
+ * @param {string} modelId - The model id
33329
+ * @param {Object} [options] - Optional parameters
33330
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
33331
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
33332
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
33333
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
33334
+ * @returns {Promise<string[]>} Array of model file paths
33335
+ *
33336
+ * @example
33337
+ * const files = await ModelRegistry.get_model_files('onnx-community/bert-base-uncased-ONNX');
33338
+ * console.log(files); // ['config.json', 'onnx/model_q4.onnx', 'generation_config.json']
33339
+ */
33340
+ static async get_model_files(modelId, options = {}) {
33341
+ return get_model_files(modelId, options);
33342
+ }
33343
+ /**
33344
+ * Get tokenizer files needed for a specific model.
33345
+ *
33346
+ * @param {string} modelId - The model id
33347
+ * @returns {Promise<string[]>} Array of tokenizer file paths
33348
+ *
33349
+ * @example
33350
+ * const files = await ModelRegistry.get_tokenizer_files('onnx-community/gpt2-ONNX');
33351
+ * console.log(files); // ['tokenizer.json', 'tokenizer_config.json']
33352
+ */
33353
+ static async get_tokenizer_files(modelId) {
33354
+ return get_tokenizer_files(modelId);
33355
+ }
33356
+ /**
33357
+ * Get processor files needed for a specific model.
33358
+ *
33359
+ * @param {string} modelId - The model id
33360
+ * @returns {Promise<string[]>} Array of processor file paths
33361
+ *
33362
+ * @example
33363
+ * const files = await ModelRegistry.get_processor_files('onnx-community/vit-base-patch16-224-ONNX');
33364
+ * console.log(files); // ['preprocessor_config.json']
33365
+ */
33366
+ static async get_processor_files(modelId) {
33367
+ return get_processor_files(modelId);
33368
+ }
33369
+ /**
33370
+ * Detects which quantization levels (dtypes) are available for a model
33371
+ * by checking which ONNX files exist on the hub or locally.
33372
+ *
33373
+ * A dtype is considered available if all required model session files
33374
+ * exist for that dtype.
33375
+ *
33376
+ * @param {string} modelId - The model id (e.g., "onnx-community/all-MiniLM-L6-v2-ONNX")
33377
+ * @param {Object} [options] - Optional parameters
33378
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
33379
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
33380
+ * @param {string} [options.revision='main'] - Model revision
33381
+ * @param {string} [options.cache_dir=null] - Custom cache directory
33382
+ * @param {boolean} [options.local_files_only=false] - Only check local files
33383
+ * @returns {Promise<string[]>} Array of available dtype strings (e.g., ['fp32', 'fp16', 'q4', 'q8'])
33384
+ *
33385
+ * @example
33386
+ * const dtypes = await ModelRegistry.get_available_dtypes('onnx-community/all-MiniLM-L6-v2-ONNX');
33387
+ * console.log(dtypes); // ['fp32', 'fp16', 'int8', 'uint8', 'q8', 'q4']
33388
+ */
33389
+ static async get_available_dtypes(modelId, options = {}) {
33390
+ return get_available_dtypes(modelId, options);
33391
+ }
33392
+ /**
33393
+ * Quickly checks if a model is fully cached by verifying `config.json` is present,
33394
+ * then confirming all required files are cached.
33395
+ * Returns a plain boolean — use `is_cached_files` if you need per-file detail.
33396
+ *
33397
+ * @param {string} modelId - The model id
33398
+ * @param {Object} [options] - Optional parameters
33399
+ * @param {string} [options.cache_dir] - Custom cache directory
33400
+ * @param {string} [options.revision] - Model revision (default: 'main')
33401
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
33402
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
33403
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
33404
+ * @returns {Promise<boolean>} Whether all required files are cached
33405
+ *
33406
+ * @example
33407
+ * const cached = await ModelRegistry.is_cached('onnx-community/bert-base-uncased-ONNX');
33408
+ * console.log(cached); // true or false
33409
+ */
33410
+ static async is_cached(modelId, options = {}) {
33411
+ return is_cached(modelId, options);
33412
+ }
33413
+ /**
33414
+ * Checks if all files for a given model are already cached, with per-file detail.
33415
+ * Automatically determines which files are needed using get_files().
33416
+ *
33417
+ * @param {string} modelId - The model id
33418
+ * @param {Object} [options] - Optional parameters
33419
+ * @param {string} [options.cache_dir] - Custom cache directory
33420
+ * @param {string} [options.revision] - Model revision (default: 'main')
33421
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
33422
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
33423
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
33424
+ * @returns {Promise<import('./is_cached.js').CacheCheckResult>} Object with allCached boolean and files array with cache status
33425
+ *
33426
+ * @example
33427
+ * const status = await ModelRegistry.is_cached_files('onnx-community/bert-base-uncased-ONNX');
33428
+ * console.log(status.allCached); // true or false
33429
+ * console.log(status.files); // [{ file: 'config.json', cached: true }, ...]
33430
+ */
33431
+ static async is_cached_files(modelId, options = {}) {
33432
+ return is_cached_files(modelId, options);
33433
+ }
33434
+ /**
33435
+ * Quickly checks if all files for a specific pipeline task are cached by verifying
33436
+ * `config.json` is present, then confirming all required files are cached.
33437
+ * Returns a plain boolean — use `is_pipeline_cached_files` if you need per-file detail.
33438
+ *
33439
+ * @param {string} task - The pipeline task (e.g., "text-generation", "background-removal")
33440
+ * @param {string} modelId - The model id
33441
+ * @param {Object} [options] - Optional parameters
33442
+ * @param {string} [options.cache_dir] - Custom cache directory
33443
+ * @param {string} [options.revision] - Model revision (default: 'main')
33444
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
33445
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
33446
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
33447
+ * @returns {Promise<boolean>} Whether all required files are cached
33448
+ *
33449
+ * @example
33450
+ * const cached = await ModelRegistry.is_pipeline_cached('text-generation', 'onnx-community/gpt2-ONNX');
33451
+ * console.log(cached); // true or false
33452
+ */
33453
+ static async is_pipeline_cached(task, modelId, options = {}) {
33454
+ return is_pipeline_cached(task, modelId, options);
33455
+ }
33456
+ /**
33457
+ * Checks if all files for a specific pipeline task are already cached, with per-file detail.
33458
+ * Automatically determines which components are needed based on the task.
33459
+ *
33460
+ * @param {string} task - The pipeline task (e.g., "text-generation", "background-removal")
33461
+ * @param {string} modelId - The model id
33462
+ * @param {Object} [options] - Optional parameters
33463
+ * @param {string} [options.cache_dir] - Custom cache directory
33464
+ * @param {string} [options.revision] - Model revision (default: 'main')
33465
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
33466
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
33467
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
33468
+ * @returns {Promise<import('./is_cached.js').CacheCheckResult>} Object with allCached boolean and files array with cache status
33469
+ *
33470
+ * @example
33471
+ * const status = await ModelRegistry.is_pipeline_cached_files('text-generation', 'onnx-community/gpt2-ONNX');
33472
+ * console.log(status.allCached); // true or false
33473
+ * console.log(status.files); // [{ file: 'config.json', cached: true }, ...]
33474
+ */
33475
+ static async is_pipeline_cached_files(task, modelId, options = {}) {
33476
+ return is_pipeline_cached_files(task, modelId, options);
33477
+ }
33478
+ /**
33479
+ * Get metadata for a specific file without downloading it.
33480
+ *
33481
+ * @param {string} path_or_repo_id - Model id or path
33482
+ * @param {string} filename - The file name
33483
+ * @param {import('../hub.js').PretrainedOptions} [options] - Optional parameters
33484
+ * @returns {Promise<{exists: boolean, size?: number, contentType?: string, fromCache?: boolean}>} File metadata
33485
+ *
33486
+ * @example
33487
+ * const metadata = await ModelRegistry.get_file_metadata('onnx-community/gpt2-ONNX', 'config.json');
33488
+ * console.log(metadata.exists, metadata.size); // true, 665
33489
+ */
33490
+ static async get_file_metadata(path_or_repo_id, filename, options = {}) {
33491
+ return get_file_metadata(path_or_repo_id, filename, options);
33492
+ }
33493
+ /**
33494
+ * Clears all cached files for a given model.
33495
+ * Automatically determines which files are needed and removes them from the cache.
33496
+ *
33497
+ * @param {string} modelId - The model id (e.g., "onnx-community/gpt2-ONNX")
33498
+ * @param {Object} [options] - Optional parameters
33499
+ * @param {string} [options.cache_dir] - Custom cache directory
33500
+ * @param {string} [options.revision] - Model revision (default: 'main')
33501
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
33502
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
33503
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
33504
+ * @param {boolean} [options.include_tokenizer=true] - Whether to clear tokenizer files
33505
+ * @param {boolean} [options.include_processor=true] - Whether to clear processor files
33506
+ * @returns {Promise<import('./clear_cache.js').CacheClearResult>} Object with deletion statistics and file status
33507
+ *
33508
+ * @example
33509
+ * const result = await ModelRegistry.clear_cache('onnx-community/bert-base-uncased-ONNX');
33510
+ * console.log(`Deleted ${result.filesDeleted} of ${result.filesCached} cached files`);
33511
+ */
33512
+ static async clear_cache(modelId, options = {}) {
33513
+ return clear_cache(modelId, options);
33514
+ }
33515
+ /**
33516
+ * Clears all cached files for a specific pipeline task.
33517
+ * Automatically determines which components are needed based on the task.
33518
+ *
33519
+ * @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
33520
+ * @param {string} modelId - The model id (e.g., "onnx-community/gpt2-ONNX")
33521
+ * @param {Object} [options] - Optional parameters
33522
+ * @param {string} [options.cache_dir] - Custom cache directory
33523
+ * @param {string} [options.revision] - Model revision (default: 'main')
33524
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
33525
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
33526
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
33527
+ * @returns {Promise<import('./clear_cache.js').CacheClearResult>} Object with deletion statistics and file status
33528
+ *
33529
+ * @example
33530
+ * const result = await ModelRegistry.clear_pipeline_cache('text-generation', 'onnx-community/gpt2-ONNX');
33531
+ * console.log(`Deleted ${result.filesDeleted} of ${result.filesCached} cached files`);
33532
+ */
33533
+ static async clear_pipeline_cache(task, modelId, options = {}) {
33534
+ return clear_pipeline_cache(task, modelId, options);
33535
+ }
33536
+ };
32756
33537
  export {
32757
33538
  ASTFeatureExtractor,
32758
33539
  ASTForAudioClassification,
@@ -32779,16 +33560,23 @@ export {
32779
33560
  AutoImageProcessor,
32780
33561
  AutoModel,
32781
33562
  AutoModelForAudioClassification,
33563
+ AutoModelForAudioFrameClassification,
33564
+ AutoModelForAudioTextToText,
32782
33565
  AutoModelForCTC,
32783
33566
  AutoModelForCausalLM,
32784
33567
  AutoModelForDepthEstimation,
32785
33568
  AutoModelForDocumentQuestionAnswering,
32786
33569
  AutoModelForImageClassification,
32787
33570
  AutoModelForImageFeatureExtraction,
33571
+ AutoModelForImageMatting,
32788
33572
  AutoModelForImageSegmentation,
33573
+ AutoModelForImageTextToText,
32789
33574
  AutoModelForImageToImage,
33575
+ AutoModelForMaskGeneration,
32790
33576
  AutoModelForMaskedLM,
33577
+ AutoModelForNormalEstimation,
32791
33578
  AutoModelForObjectDetection,
33579
+ AutoModelForPoseEstimation,
32792
33580
  AutoModelForQuestionAnswering,
32793
33581
  AutoModelForSemanticSegmentation,
32794
33582
  AutoModelForSeq2SeqLM,
@@ -32799,6 +33587,7 @@ export {
32799
33587
  AutoModelForTokenClassification,
32800
33588
  AutoModelForUniversalSegmentation,
32801
33589
  AutoModelForVision2Seq,
33590
+ AutoModelForXVector,
32802
33591
  AutoModelForZeroShotObjectDetection,
32803
33592
  AutoProcessor,
32804
33593
  AutoTokenizer,
@@ -32809,6 +33598,7 @@ export {
32809
33598
  BartModel,
32810
33599
  BartPretrainedModel,
32811
33600
  BartTokenizer,
33601
+ BaseStreamer,
32812
33602
  BeitFeatureExtractor,
32813
33603
  BeitForImageClassification,
32814
33604
  BeitModel,
@@ -33124,6 +33914,7 @@ export {
33124
33914
  ImageSegmentationPipeline,
33125
33915
  ImageToImagePipeline,
33126
33916
  ImageToTextPipeline,
33917
+ InterruptableStoppingCriteria,
33127
33918
  JAISLMHeadModel,
33128
33919
  JAISModel,
33129
33920
  JAISPreTrainedModel,
@@ -33259,6 +34050,7 @@ export {
33259
34050
  MobileViTV2ForImageClassification,
33260
34051
  MobileViTV2Model,
33261
34052
  MobileViTV2PreTrainedModel,
34053
+ ModelRegistry,
33262
34054
  ModernBertDecoderForCausalLM,
33263
34055
  ModernBertDecoderModel,
33264
34056
  ModernBertDecoderPreTrainedModel,
@@ -33418,6 +34210,8 @@ export {
33418
34210
  RTDetrV2PreTrainedModel,
33419
34211
  RawAudio,
33420
34212
  RawImage,
34213
+ RawVideo,
34214
+ RawVideoFrame,
33421
34215
  RepetitionPenaltyLogitsProcessor,
33422
34216
  ResNetForImageClassification,
33423
34217
  ResNetModel,
@@ -33532,9 +34326,12 @@ export {
33532
34326
  Text2TextGenerationPipeline,
33533
34327
  TextClassificationPipeline,
33534
34328
  TextGenerationPipeline,
34329
+ TextStreamer,
33535
34330
  TextToAudioPipeline,
33536
34331
  TokenClassificationPipeline,
33537
34332
  PreTrainedTokenizer as TokenizersBackend,
34333
+ TopKLogitsWarper,
34334
+ TopPLogitsWarper,
33538
34335
  TrOCRForCausalLM,
33539
34336
  TrOCRPreTrainedModel,
33540
34337
  TranslationPipeline,
@@ -33609,6 +34406,7 @@ export {
33609
34406
  WhisperModel,
33610
34407
  WhisperPreTrainedModel,
33611
34408
  WhisperProcessor,
34409
+ WhisperTextStreamer,
33612
34410
  WhisperTimeStampLogitsProcessor,
33613
34411
  WhisperTokenizer,
33614
34412
  XLMForQuestionAnswering,
@@ -33640,12 +34438,17 @@ export {
33640
34438
  ZeroShotImageClassificationPipeline,
33641
34439
  ZeroShotObjectDetectionPipeline,
33642
34440
  cat,
34441
+ cos_sim,
34442
+ dot,
33643
34443
  env,
33644
34444
  full,
33645
34445
  full_like,
33646
34446
  interpolate,
33647
34447
  interpolate_4d,
34448
+ layer_norm,
33648
34449
  load_audio,
34450
+ load_image,
34451
+ load_video,
33649
34452
  log_softmax,
33650
34453
  matmul,
33651
34454
  mean,
@@ -33655,9 +34458,11 @@ export {
33655
34458
  permute,
33656
34459
  pipeline2 as pipeline,
33657
34460
  quantize_embeddings,
34461
+ rand,
33658
34462
  randn,
33659
34463
  random,
33660
34464
  read_audio,
34465
+ rfft,
33661
34466
  slice2 as slice,
33662
34467
  softmax,
33663
34468
  stack,