@huggingface/transformers 4.0.0-next.4 → 4.0.0-next.6

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 (187) hide show
  1. package/README.md +15 -5
  2. package/dist/ort-wasm-simd-threaded.jsep.mjs +28 -28
  3. package/dist/transformers.js +3446 -2296
  4. package/dist/transformers.min.js +17 -19
  5. package/dist/transformers.node.cjs +3456 -2263
  6. package/dist/transformers.node.min.cjs +20 -22
  7. package/dist/transformers.node.min.mjs +20 -22
  8. package/dist/transformers.node.mjs +3426 -2258
  9. package/dist/transformers.web.js +1647 -471
  10. package/dist/transformers.web.min.js +18 -18
  11. package/package.json +4 -4
  12. package/src/backends/onnx.js +128 -53
  13. package/src/backends/utils/cacheWasm.js +28 -46
  14. package/src/configs.js +63 -3
  15. package/src/env.js +93 -11
  16. package/src/generation/logits_sampler.js +3 -15
  17. package/src/image_processors_utils.js +2 -6
  18. package/src/models/afmoe/modeling_afmoe.js +5 -0
  19. package/src/models/auto/image_processing_auto.js +2 -1
  20. package/src/models/auto/modeling_auto.js +16 -2
  21. package/src/models/auto/tokenization_auto.js +2 -1
  22. package/src/models/clap/feature_extraction_clap.js +2 -1
  23. package/src/models/marian/tokenization_marian.js +3 -2
  24. package/src/models/modeling_utils.js +45 -7
  25. package/src/models/models.js +10 -0
  26. package/src/models/olmo_hybrid/modeling_olmo_hybrid.js +5 -0
  27. package/src/models/paligemma/processing_paligemma.js +3 -2
  28. package/src/models/processors.js +2 -0
  29. package/src/models/qwen2_5_vl/modeling_qwen2_5_vl.js +5 -0
  30. package/src/models/qwen2_5_vl/processing_qwen2_5_vl.js +3 -0
  31. package/src/models/qwen2_moe/modeling_qwen2_moe.js +5 -0
  32. package/src/models/qwen2_vl/image_processing_qwen2_vl.js +54 -0
  33. package/src/models/qwen2_vl/modeling_qwen2_vl.js +45 -6
  34. package/src/models/qwen3_5/modeling_qwen3_5.js +3 -0
  35. package/src/models/qwen3_5_moe/modeling_qwen3_5_moe.js +3 -0
  36. package/src/models/qwen3_moe/modeling_qwen3_moe.js +5 -0
  37. package/src/models/qwen3_next/modeling_qwen3_next.js +5 -0
  38. package/src/models/qwen3_vl/modeling_qwen3_vl.js +3 -0
  39. package/src/models/qwen3_vl/processing_qwen3_vl.js +3 -0
  40. package/src/models/qwen3_vl_moe/modeling_qwen3_vl_moe.js +3 -0
  41. package/src/models/registry.js +21 -5
  42. package/src/models/session.js +16 -50
  43. package/src/models/whisper/feature_extraction_whisper.js +2 -1
  44. package/src/models/whisper/modeling_whisper.js +6 -5
  45. package/src/models/xlm/tokenization_xlm.js +2 -1
  46. package/src/pipelines/automatic-speech-recognition.js +3 -2
  47. package/src/pipelines/index.js +313 -0
  48. package/src/pipelines/text-generation.js +4 -0
  49. package/src/pipelines/text-to-audio.js +4 -2
  50. package/src/pipelines/zero-shot-classification.js +3 -2
  51. package/src/pipelines.js +139 -428
  52. package/src/tokenization_utils.js +42 -21
  53. package/src/transformers.js +6 -1
  54. package/src/utils/audio.js +2 -1
  55. package/src/utils/cache/FileCache.js +128 -0
  56. package/src/utils/cache.js +7 -4
  57. package/src/utils/core.js +23 -1
  58. package/src/utils/devices.js +22 -0
  59. package/src/utils/dtypes.js +55 -0
  60. package/src/utils/hub/{files.js → FileResponse.js} +0 -90
  61. package/src/utils/hub/utils.js +45 -5
  62. package/src/utils/hub.js +63 -22
  63. package/src/utils/image.js +14 -14
  64. package/src/utils/logger.js +67 -0
  65. package/src/utils/model-loader.js +35 -17
  66. package/src/utils/model_registry/ModelRegistry.js +346 -0
  67. package/src/utils/model_registry/clear_cache.js +128 -0
  68. package/src/utils/model_registry/get_file_metadata.js +149 -0
  69. package/src/utils/model_registry/get_files.js +42 -0
  70. package/src/utils/model_registry/get_model_files.js +193 -0
  71. package/src/utils/model_registry/get_pipeline_files.js +44 -0
  72. package/src/utils/model_registry/get_processor_files.js +20 -0
  73. package/src/utils/model_registry/get_tokenizer_files.js +21 -0
  74. package/src/utils/model_registry/is_cached.js +169 -0
  75. package/src/utils/random.js +225 -0
  76. package/src/utils/tensor.js +8 -21
  77. package/src/utils/video.js +2 -2
  78. package/types/backends/onnx.d.ts.map +1 -1
  79. package/types/backends/utils/cacheWasm.d.ts +3 -17
  80. package/types/backends/utils/cacheWasm.d.ts.map +1 -1
  81. package/types/configs.d.ts.map +1 -1
  82. package/types/env.d.ts +52 -27
  83. package/types/env.d.ts.map +1 -1
  84. package/types/generation/logits_sampler.d.ts +2 -2
  85. package/types/generation/logits_sampler.d.ts.map +1 -1
  86. package/types/image_processors_utils.d.ts.map +1 -1
  87. package/types/models/afmoe/modeling_afmoe.d.ts +8 -0
  88. package/types/models/afmoe/modeling_afmoe.d.ts.map +1 -0
  89. package/types/models/auto/image_processing_auto.d.ts.map +1 -1
  90. package/types/models/auto/modeling_auto.d.ts +6 -0
  91. package/types/models/auto/modeling_auto.d.ts.map +1 -1
  92. package/types/models/auto/tokenization_auto.d.ts.map +1 -1
  93. package/types/models/clap/feature_extraction_clap.d.ts.map +1 -1
  94. package/types/models/marian/tokenization_marian.d.ts.map +1 -1
  95. package/types/models/modeling_utils.d.ts +13 -2
  96. package/types/models/modeling_utils.d.ts.map +1 -1
  97. package/types/models/models.d.ts +10 -0
  98. package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts +8 -0
  99. package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts.map +1 -0
  100. package/types/models/paligemma/processing_paligemma.d.ts.map +1 -1
  101. package/types/models/processors.d.ts +2 -0
  102. package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts +4 -0
  103. package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts.map +1 -0
  104. package/types/models/qwen2_5_vl/processing_qwen2_5_vl.d.ts +4 -0
  105. package/types/models/qwen2_5_vl/processing_qwen2_5_vl.d.ts.map +1 -0
  106. package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts +8 -0
  107. package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts.map +1 -0
  108. package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts +3 -0
  109. package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts.map +1 -1
  110. package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts +1 -0
  111. package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts.map +1 -1
  112. package/types/models/qwen3_5/modeling_qwen3_5.d.ts +4 -0
  113. package/types/models/qwen3_5/modeling_qwen3_5.d.ts.map +1 -0
  114. package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts +4 -0
  115. package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts.map +1 -0
  116. package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts +8 -0
  117. package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts.map +1 -0
  118. package/types/models/qwen3_next/modeling_qwen3_next.d.ts +8 -0
  119. package/types/models/qwen3_next/modeling_qwen3_next.d.ts.map +1 -0
  120. package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts +4 -0
  121. package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts.map +1 -0
  122. package/types/models/qwen3_vl/processing_qwen3_vl.d.ts +4 -0
  123. package/types/models/qwen3_vl/processing_qwen3_vl.d.ts.map +1 -0
  124. package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts +4 -0
  125. package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts.map +1 -0
  126. package/types/models/registry.d.ts +2 -1
  127. package/types/models/registry.d.ts.map +1 -1
  128. package/types/models/session.d.ts.map +1 -1
  129. package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
  130. package/types/models/whisper/modeling_whisper.d.ts.map +1 -1
  131. package/types/models/xlm/tokenization_xlm.d.ts.map +1 -1
  132. package/types/pipelines/automatic-speech-recognition.d.ts.map +1 -1
  133. package/types/pipelines/index.d.ts +265 -0
  134. package/types/pipelines/index.d.ts.map +1 -0
  135. package/types/pipelines/text-generation.d.ts +5 -1
  136. package/types/pipelines/text-generation.d.ts.map +1 -1
  137. package/types/pipelines/text-to-audio.d.ts.map +1 -1
  138. package/types/pipelines/zero-shot-classification.d.ts.map +1 -1
  139. package/types/pipelines.d.ts +50 -291
  140. package/types/pipelines.d.ts.map +1 -1
  141. package/types/tokenization_utils.d.ts +44 -26
  142. package/types/tokenization_utils.d.ts.map +1 -1
  143. package/types/transformers.d.ts +4 -1
  144. package/types/transformers.d.ts.map +1 -1
  145. package/types/utils/audio.d.ts.map +1 -1
  146. package/types/utils/cache/FileCache.d.ts +39 -0
  147. package/types/utils/cache/FileCache.d.ts.map +1 -0
  148. package/types/utils/cache.d.ts +10 -4
  149. package/types/utils/cache.d.ts.map +1 -1
  150. package/types/utils/core.d.ts +59 -2
  151. package/types/utils/core.d.ts.map +1 -1
  152. package/types/utils/devices.d.ts +15 -0
  153. package/types/utils/devices.d.ts.map +1 -1
  154. package/types/utils/dtypes.d.ts +16 -0
  155. package/types/utils/dtypes.d.ts.map +1 -1
  156. package/types/utils/hub/{files.d.ts → FileResponse.d.ts} +1 -32
  157. package/types/utils/hub/FileResponse.d.ts.map +1 -0
  158. package/types/utils/hub/utils.d.ts +19 -3
  159. package/types/utils/hub/utils.d.ts.map +1 -1
  160. package/types/utils/hub.d.ts +36 -7
  161. package/types/utils/hub.d.ts.map +1 -1
  162. package/types/utils/logger.d.ts +28 -0
  163. package/types/utils/logger.d.ts.map +1 -0
  164. package/types/utils/model-loader.d.ts +15 -0
  165. package/types/utils/model-loader.d.ts.map +1 -1
  166. package/types/utils/model_registry/ModelRegistry.d.ts +271 -0
  167. package/types/utils/model_registry/ModelRegistry.d.ts.map +1 -0
  168. package/types/utils/model_registry/clear_cache.d.ts +74 -0
  169. package/types/utils/model_registry/clear_cache.d.ts.map +1 -0
  170. package/types/utils/model_registry/get_file_metadata.d.ts +20 -0
  171. package/types/utils/model_registry/get_file_metadata.d.ts.map +1 -0
  172. package/types/utils/model_registry/get_files.d.ts +23 -0
  173. package/types/utils/model_registry/get_files.d.ts.map +1 -0
  174. package/types/utils/model_registry/get_model_files.d.ts +22 -0
  175. package/types/utils/model_registry/get_model_files.d.ts.map +1 -0
  176. package/types/utils/model_registry/get_pipeline_files.d.ts +22 -0
  177. package/types/utils/model_registry/get_pipeline_files.d.ts.map +1 -0
  178. package/types/utils/model_registry/get_processor_files.d.ts +9 -0
  179. package/types/utils/model_registry/get_processor_files.d.ts.map +1 -0
  180. package/types/utils/model_registry/get_tokenizer_files.d.ts +9 -0
  181. package/types/utils/model_registry/get_tokenizer_files.d.ts.map +1 -0
  182. package/types/utils/model_registry/is_cached.d.ts +105 -0
  183. package/types/utils/model_registry/is_cached.d.ts.map +1 -0
  184. package/types/utils/random.d.ts +86 -0
  185. package/types/utils/random.d.ts.map +1 -0
  186. package/types/utils/tensor.d.ts.map +1 -1
  187. package/types/utils/hub/files.d.ts.map +0 -1
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Static class for cache and file management operations.
3
+ * @hideconstructor
4
+ */
5
+ export class ModelRegistry {
6
+ /**
7
+ * Get all files (model, tokenizer, processor) needed for a model.
8
+ *
9
+ * @param {string} modelId - The model id (e.g., "onnx-community/bert-base-uncased-ONNX")
10
+ * @param {Object} [options] - Optional parameters
11
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
12
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
13
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
14
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
15
+ * @param {boolean} [options.include_tokenizer=true] - Whether to check for tokenizer files
16
+ * @param {boolean} [options.include_processor=true] - Whether to check for processor files
17
+ * @returns {Promise<string[]>} Array of file paths
18
+ *
19
+ * @example
20
+ * const files = await ModelRegistry.get_files('onnx-community/gpt2-ONNX');
21
+ * console.log(files); // ['config.json', 'tokenizer.json', 'onnx/model_q4.onnx', ...]
22
+ */
23
+ static get_files(modelId: string, options?: {
24
+ config?: import("../../configs.js").PretrainedConfig;
25
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
26
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
27
+ model_file_name?: string;
28
+ include_tokenizer?: boolean;
29
+ include_processor?: boolean;
30
+ }): Promise<string[]>;
31
+ /**
32
+ * Get all files needed for a specific pipeline task.
33
+ * Automatically determines which components are needed based on the task.
34
+ *
35
+ * @param {string} task - The pipeline task (e.g., "text-generation", "background-removal")
36
+ * @param {string} modelId - The model id (e.g., "onnx-community/bert-base-uncased-ONNX")
37
+ * @param {Object} [options] - Optional parameters
38
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
39
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
40
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
41
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
42
+ * @returns {Promise<string[]>} Array of file paths
43
+ *
44
+ * @example
45
+ * const files = await ModelRegistry.get_pipeline_files('text-generation', 'onnx-community/gpt2-ONNX');
46
+ * console.log(files); // ['config.json', 'tokenizer.json', 'onnx/model_q4.onnx', ...]
47
+ */
48
+ static get_pipeline_files(task: string, modelId: string, options?: {
49
+ config?: import("../../configs.js").PretrainedConfig;
50
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
51
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
52
+ model_file_name?: string;
53
+ }): Promise<string[]>;
54
+ /**
55
+ * Get model files needed for a specific model.
56
+ *
57
+ * @param {string} modelId - The model id
58
+ * @param {Object} [options] - Optional parameters
59
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
60
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
61
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
62
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
63
+ * @returns {Promise<string[]>} Array of model file paths
64
+ *
65
+ * @example
66
+ * const files = await ModelRegistry.get_model_files('onnx-community/bert-base-uncased-ONNX');
67
+ * console.log(files); // ['config.json', 'onnx/model_q4.onnx', 'generation_config.json']
68
+ */
69
+ static get_model_files(modelId: string, options?: {
70
+ config?: import("../../configs.js").PretrainedConfig;
71
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
72
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
73
+ model_file_name?: string;
74
+ }): Promise<string[]>;
75
+ /**
76
+ * Get tokenizer files needed for a specific model.
77
+ *
78
+ * @param {string} modelId - The model id
79
+ * @returns {Promise<string[]>} Array of tokenizer file paths
80
+ *
81
+ * @example
82
+ * const files = await ModelRegistry.get_tokenizer_files('onnx-community/gpt2-ONNX');
83
+ * console.log(files); // ['tokenizer.json', 'tokenizer_config.json']
84
+ */
85
+ static get_tokenizer_files(modelId: string): Promise<string[]>;
86
+ /**
87
+ * Get processor files needed for a specific model.
88
+ *
89
+ * @param {string} modelId - The model id
90
+ * @returns {Promise<string[]>} Array of processor file paths
91
+ *
92
+ * @example
93
+ * const files = await ModelRegistry.get_processor_files('onnx-community/vit-base-patch16-224-ONNX');
94
+ * console.log(files); // ['preprocessor_config.json']
95
+ */
96
+ static get_processor_files(modelId: string): Promise<string[]>;
97
+ /**
98
+ * Quickly checks if a model is fully cached by verifying `config.json` is present,
99
+ * then confirming all required files are cached.
100
+ * Returns a plain boolean — use `is_cached_files` if you need per-file detail.
101
+ *
102
+ * @param {string} modelId - The model id
103
+ * @param {Object} [options] - Optional parameters
104
+ * @param {string} [options.cache_dir] - Custom cache directory
105
+ * @param {string} [options.revision] - Model revision (default: 'main')
106
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
107
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
108
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
109
+ * @returns {Promise<boolean>} Whether all required files are cached
110
+ *
111
+ * @example
112
+ * const cached = await ModelRegistry.is_cached('onnx-community/bert-base-uncased-ONNX');
113
+ * console.log(cached); // true or false
114
+ */
115
+ static is_cached(modelId: string, options?: {
116
+ cache_dir?: string;
117
+ revision?: string;
118
+ config?: import("../../configs.js").PretrainedConfig;
119
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
120
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
121
+ }): Promise<boolean>;
122
+ /**
123
+ * Checks if all files for a given model are already cached, with per-file detail.
124
+ * Automatically determines which files are needed using get_files().
125
+ *
126
+ * @param {string} modelId - The model id
127
+ * @param {Object} [options] - Optional parameters
128
+ * @param {string} [options.cache_dir] - Custom cache directory
129
+ * @param {string} [options.revision] - Model revision (default: 'main')
130
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
131
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
132
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
133
+ * @returns {Promise<import('./is_cached.js').CacheCheckResult>} Object with allCached boolean and files array with cache status
134
+ *
135
+ * @example
136
+ * const status = await ModelRegistry.is_cached_files('onnx-community/bert-base-uncased-ONNX');
137
+ * console.log(status.allCached); // true or false
138
+ * console.log(status.files); // [{ file: 'config.json', cached: true }, ...]
139
+ */
140
+ static is_cached_files(modelId: string, options?: {
141
+ cache_dir?: string;
142
+ revision?: string;
143
+ config?: import("../../configs.js").PretrainedConfig;
144
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
145
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
146
+ }): Promise<import("./is_cached.js").CacheCheckResult>;
147
+ /**
148
+ * Quickly checks if all files for a specific pipeline task are cached by verifying
149
+ * `config.json` is present, then confirming all required files are cached.
150
+ * Returns a plain boolean — use `is_pipeline_cached_files` if you need per-file detail.
151
+ *
152
+ * @param {string} task - The pipeline task (e.g., "text-generation", "background-removal")
153
+ * @param {string} modelId - The model id
154
+ * @param {Object} [options] - Optional parameters
155
+ * @param {string} [options.cache_dir] - Custom cache directory
156
+ * @param {string} [options.revision] - Model revision (default: 'main')
157
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
158
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
159
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
160
+ * @returns {Promise<boolean>} Whether all required files are cached
161
+ *
162
+ * @example
163
+ * const cached = await ModelRegistry.is_pipeline_cached('text-generation', 'onnx-community/gpt2-ONNX');
164
+ * console.log(cached); // true or false
165
+ */
166
+ static is_pipeline_cached(task: string, modelId: string, options?: {
167
+ cache_dir?: string;
168
+ revision?: string;
169
+ config?: import("../../configs.js").PretrainedConfig;
170
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
171
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
172
+ }): Promise<boolean>;
173
+ /**
174
+ * Checks if all files for a specific pipeline task are already cached, with per-file detail.
175
+ * Automatically determines which components are needed based on the task.
176
+ *
177
+ * @param {string} task - The pipeline task (e.g., "text-generation", "background-removal")
178
+ * @param {string} modelId - The model id
179
+ * @param {Object} [options] - Optional parameters
180
+ * @param {string} [options.cache_dir] - Custom cache directory
181
+ * @param {string} [options.revision] - Model revision (default: 'main')
182
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
183
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
184
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
185
+ * @returns {Promise<import('./is_cached.js').CacheCheckResult>} Object with allCached boolean and files array with cache status
186
+ *
187
+ * @example
188
+ * const status = await ModelRegistry.is_pipeline_cached_files('text-generation', 'onnx-community/gpt2-ONNX');
189
+ * console.log(status.allCached); // true or false
190
+ * console.log(status.files); // [{ file: 'config.json', cached: true }, ...]
191
+ */
192
+ static is_pipeline_cached_files(task: string, modelId: string, options?: {
193
+ cache_dir?: string;
194
+ revision?: string;
195
+ config?: import("../../configs.js").PretrainedConfig;
196
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
197
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
198
+ }): Promise<import("./is_cached.js").CacheCheckResult>;
199
+ /**
200
+ * Get metadata for a specific file without downloading it.
201
+ *
202
+ * @param {string} path_or_repo_id - Model id or path
203
+ * @param {string} filename - The file name
204
+ * @param {import('../hub.js').PretrainedOptions} [options] - Optional parameters
205
+ * @returns {Promise<{exists: boolean, size?: number, contentType?: string, fromCache?: boolean}>} File metadata
206
+ *
207
+ * @example
208
+ * const metadata = await ModelRegistry.get_file_metadata('onnx-community/gpt2-ONNX', 'config.json');
209
+ * console.log(metadata.exists, metadata.size); // true, 665
210
+ */
211
+ static get_file_metadata(path_or_repo_id: string, filename: string, options?: import("../hub.js").PretrainedOptions): Promise<{
212
+ exists: boolean;
213
+ size?: number;
214
+ contentType?: string;
215
+ fromCache?: boolean;
216
+ }>;
217
+ /**
218
+ * Clears all cached files for a given model.
219
+ * Automatically determines which files are needed and removes them from the cache.
220
+ *
221
+ * @param {string} modelId - The model id (e.g., "onnx-community/gpt2-ONNX")
222
+ * @param {Object} [options] - Optional parameters
223
+ * @param {string} [options.cache_dir] - Custom cache directory
224
+ * @param {string} [options.revision] - Model revision (default: 'main')
225
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
226
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
227
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
228
+ * @param {boolean} [options.include_tokenizer=true] - Whether to clear tokenizer files
229
+ * @param {boolean} [options.include_processor=true] - Whether to clear processor files
230
+ * @returns {Promise<import('./clear_cache.js').CacheClearResult>} Object with deletion statistics and file status
231
+ *
232
+ * @example
233
+ * const result = await ModelRegistry.clear_cache('onnx-community/bert-base-uncased-ONNX');
234
+ * console.log(`Deleted ${result.filesDeleted} of ${result.filesCached} cached files`);
235
+ */
236
+ static clear_cache(modelId: string, options?: {
237
+ cache_dir?: string;
238
+ revision?: string;
239
+ config?: import("../../configs.js").PretrainedConfig;
240
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
241
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
242
+ include_tokenizer?: boolean;
243
+ include_processor?: boolean;
244
+ }): Promise<import("./clear_cache.js").CacheClearResult>;
245
+ /**
246
+ * Clears all cached files for a specific pipeline task.
247
+ * Automatically determines which components are needed based on the task.
248
+ *
249
+ * @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
250
+ * @param {string} modelId - The model id (e.g., "onnx-community/gpt2-ONNX")
251
+ * @param {Object} [options] - Optional parameters
252
+ * @param {string} [options.cache_dir] - Custom cache directory
253
+ * @param {string} [options.revision] - Model revision (default: 'main')
254
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
255
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
256
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
257
+ * @returns {Promise<import('./clear_cache.js').CacheClearResult>} Object with deletion statistics and file status
258
+ *
259
+ * @example
260
+ * const result = await ModelRegistry.clear_pipeline_cache('text-generation', 'onnx-community/gpt2-ONNX');
261
+ * console.log(`Deleted ${result.filesDeleted} of ${result.filesCached} cached files`);
262
+ */
263
+ static clear_pipeline_cache(task: string, modelId: string, options?: {
264
+ cache_dir?: string;
265
+ revision?: string;
266
+ config?: import("../../configs.js").PretrainedConfig;
267
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
268
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
269
+ }): Promise<import("./clear_cache.js").CacheClearResult>;
270
+ }
271
+ //# sourceMappingURL=ModelRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelRegistry.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/ModelRegistry.js"],"names":[],"mappings":"AAqGA;;;GAGG;AACH;IACI;;;;;;;;;;;;;;;;OAgBG;IACH,0BAdW,MAAM,YAEd;QAA8D,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;QAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;QACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;QACpE,eAAe,GAAhC,MAAM;QACY,iBAAiB,GAAnC,OAAO;QACW,iBAAiB,GAAnC,OAAO;KACf,GAAU,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ7B;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,gCAbW,MAAM,WACN,MAAM,YAEd;QAA8D,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;QAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;QACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU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,EAAE,iBAAiB,GACnC,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC,CAQhG;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,4BAfW,MAAM,YAEd;QAAyB,SAAS,GAA1B,MAAM;QACW,QAAQ,GAAzB,MAAM;QACgD,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;QAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;QACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;QACnE,iBAAiB,GAAnC,OAAO;QACW,iBAAiB,GAAnC,OAAO;KACf,GAAU,OAAO,CAAC,OAAO,kBAAkB,EAAE,gBAAgB,CAAC,CAQhE;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,kCAdW,MAAM,WACN,MAAM,YAEd;QAAyB,SAAS,GAA1B,MAAM;QACW,QAAQ,GAAzB,MAAM;QACgD,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;QAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;QACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;KAC7F,GAAU,OAAO,CAAC,OAAO,kBAAkB,EAAE,gBAAgB,CAAC,CAQhE;CACJ"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Clears all cached files for a given model.
3
+ * Automatically determines which files are needed using get_files().
4
+ *
5
+ * @param {string} modelId - The model id (e.g., "Xenova/gpt2")
6
+ * @param {Object} [options] - Optional parameters
7
+ * @param {string} [options.cache_dir] - Custom cache directory
8
+ * @param {string} [options.revision] - Model revision (default: 'main')
9
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
10
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
11
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
12
+ * @param {boolean} [options.include_tokenizer=true] - Whether to clear tokenizer files
13
+ * @param {boolean} [options.include_processor=true] - Whether to clear processor files
14
+ * @returns {Promise<CacheClearResult>} Object with deletion statistics and file status
15
+ */
16
+ export function clear_cache(modelId: string, options?: {
17
+ cache_dir?: string;
18
+ revision?: string;
19
+ config?: import("../../configs.js").PretrainedConfig;
20
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
21
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
22
+ include_tokenizer?: boolean;
23
+ include_processor?: boolean;
24
+ }): Promise<CacheClearResult>;
25
+ /**
26
+ * Clears all cached files for a specific pipeline task.
27
+ * Automatically determines which components are needed based on the task.
28
+ *
29
+ * @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
30
+ * @param {string} modelId - The model id (e.g., "Xenova/gpt2")
31
+ * @param {Object} [options] - Optional parameters
32
+ * @param {string} [options.cache_dir] - Custom cache directory
33
+ * @param {string} [options.revision] - Model revision (default: 'main')
34
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
35
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
36
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
37
+ * @returns {Promise<CacheClearResult>} Object with deletion statistics and file status
38
+ */
39
+ export function clear_pipeline_cache(task: string, modelId: string, options?: {
40
+ cache_dir?: string;
41
+ revision?: string;
42
+ config?: import("../../configs.js").PretrainedConfig;
43
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
44
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
45
+ }): Promise<CacheClearResult>;
46
+ export type FileClearStatus = {
47
+ /**
48
+ * - The file path
49
+ */
50
+ file: string;
51
+ /**
52
+ * - Whether the file was successfully deleted
53
+ */
54
+ deleted: boolean;
55
+ /**
56
+ * - Whether the file was cached before deletion
57
+ */
58
+ wasCached: boolean;
59
+ };
60
+ export type CacheClearResult = {
61
+ /**
62
+ * - Number of files successfully deleted
63
+ */
64
+ filesDeleted: number;
65
+ /**
66
+ * - Number of files that were in cache
67
+ */
68
+ filesCached: number;
69
+ /**
70
+ * - Array of files with their deletion status
71
+ */
72
+ files: FileClearStatus[];
73
+ };
74
+ //# sourceMappingURL=clear_cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear_cache.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/clear_cache.js"],"names":[],"mappings":"AA+EA;;;;;;;;;;;;;;GAcG;AACH,qCAXW,MAAM,YAEd;IAAyB,SAAS,GAA1B,MAAM;IACW,QAAQ,GAAzB,MAAM;IACgD,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;IAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;IACnE,iBAAiB,GAAnC,OAAO;IACW,iBAAiB,GAAnC,OAAO;CACf,GAAU,OAAO,CAAC,gBAAgB,CAAC,CASrC;AAED;;;;;;;;;;;;;GAaG;AACH,2CAVW,MAAM,WACN,MAAM,YAEd;IAAyB,SAAS,GAA1B,MAAM;IACW,QAAQ,GAAzB,MAAM;IACgD,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;IAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;CAC7F,GAAU,OAAO,CAAC,gBAAgB,CAAC,CAYrC;;;;;UAlHa,MAAM;;;;aACN,OAAO;;;;eACP,OAAO;;;;;;kBAKP,MAAM;;;;iBACN,MAAM;;;;WACN,eAAe,EAAE"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Gets file metadata (size, content-type, etc.) without downloading the full content.
3
+ * Uses Range requests for remote files to be efficient.
4
+ * Can also be used as a lightweight file existence check by checking the `.exists` property.
5
+ *
6
+ * @param {string} path_or_repo_id This can be either:
7
+ * - a string, the *model id* of a model repo on huggingface.co.
8
+ * - a path to a *directory* potentially containing the file.
9
+ * @param {string} filename The name of the file to check.
10
+ * @param {PretrainedOptions} [options] An object containing optional parameters.
11
+ * @returns {Promise<{exists: boolean, size?: number, contentType?: string, fromCache?: boolean}>} A Promise that resolves to file metadata.
12
+ */
13
+ export function get_file_metadata(path_or_repo_id: string, filename: string, options?: PretrainedOptions): Promise<{
14
+ exists: boolean;
15
+ size?: number;
16
+ contentType?: string;
17
+ fromCache?: boolean;
18
+ }>;
19
+ export type PretrainedOptions = import("../hub.js").PretrainedOptions;
20
+ //# sourceMappingURL=get_file_metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_file_metadata.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/get_file_metadata.js"],"names":[],"mappings":"AAuCA;;;;;;;;;;;GAWG;AACH,mDAPW,MAAM,YAGN,MAAM,YACN,iBAAiB,GACf,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAC,CAAC,CAmGhG;gCAzIY,OAAO,WAAW,EAAE,iBAAiB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Returns the list of files that will be loaded for a model based on its configuration.
3
+ * Automatically detects which files are needed (tokenizer, processor, model files).
4
+ *
5
+ * @param {string} modelId The model id (e.g., "Xenova/llama-2-7b")
6
+ * @param {Object} [options] Optional parameters
7
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] Pre-loaded model config (optional, will be fetched if not provided)
8
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] Override dtype (use this if passing dtype to pipeline)
9
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] Override device (use this if passing device to pipeline)
10
+ * @param {string|null} [options.model_file_name=null|null] Override the model file name (excluding .onnx suffix)
11
+ * @param {boolean} [options.include_tokenizer=true] Whether to check for tokenizer files (set to false for vision-only models)
12
+ * @param {boolean} [options.include_processor=true] Whether to check for processor files
13
+ * @returns {Promise<string[]>} Array of file paths that will be loaded
14
+ */
15
+ export function get_files(modelId: string, { config, dtype, device, model_file_name, include_tokenizer, include_processor, }?: {
16
+ config?: import("../../configs.js").PretrainedConfig;
17
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
18
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
19
+ model_file_name?: string | null;
20
+ include_tokenizer?: boolean;
21
+ include_processor?: boolean;
22
+ }): Promise<string[]>;
23
+ //# sourceMappingURL=get_files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_files.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/get_files.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,mCAVW,MAAM,sFAEd;IAA8D,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;IAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;IAC/D,eAAe,GAArC,MAAM,GAAC,IAAI;IACO,iBAAiB,GAAnC,OAAO;IACW,iBAAiB,GAAnC,OAAO;CACf,GAAU,OAAO,CAAC,MAAM,EAAE,CAAC,CAyB7B"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Returns the list of files that will be loaded for a model based on its configuration.
3
+ *
4
+ * This function reads configuration from the model's config.json on the hub.
5
+ * If dtype/device are not specified in the config, you can provide them to match
6
+ * what the pipeline will actually use.
7
+ *
8
+ * @param {string} modelId The model id (e.g., "onnx-community/granite-4.0-350m-ONNX-web")
9
+ * @param {Object} [options] Optional parameters
10
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] Pre-loaded model config (optional, will be fetched if not provided)
11
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] Override dtype (use this if passing dtype to pipeline)
12
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] Override device (use this if passing device to pipeline)
13
+ * @param {string} [options.model_file_name=null] Override the model file name (excluding .onnx suffix).
14
+ * @returns {Promise<string[]>} Array of file paths that will be loaded
15
+ */
16
+ export function get_model_files(modelId: string, { config, dtype: overrideDtype, device: overrideDevice, model_file_name }?: {
17
+ config?: import("../../configs.js").PretrainedConfig;
18
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
19
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
20
+ model_file_name?: string;
21
+ }): Promise<string[]>;
22
+ //# sourceMappingURL=get_model_files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_model_files.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/get_model_files.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,yCARW,MAAM,8EAEd;IAA8D,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;IAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;IACpE,eAAe,GAAhC,MAAM;CACd,GAAU,OAAO,CAAC,MAAM,EAAE,CAAC,CA2K7B"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Get all files needed for a specific pipeline task.
3
+ * Automatically detects which components (tokenizer, processor) are needed by checking
4
+ * whether the model has the corresponding files (tokenizer_config.json, preprocessor_config.json).
5
+ *
6
+ * @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
7
+ * @param {string} modelId - The model id (e.g., "Xenova/bert-base-uncased")
8
+ * @param {Object} [options] - Optional parameters
9
+ * @param {import('../../configs.js').PretrainedConfig} [options.config=null] - Pre-loaded config
10
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
11
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
12
+ * @param {string} [options.model_file_name=null] - Override the model file name (excluding .onnx suffix)
13
+ * @returns {Promise<string[]>} Array of file paths that will be loaded
14
+ * @throws {Error} If the task is not supported
15
+ */
16
+ export function get_pipeline_files(task: string, modelId: string, options?: {
17
+ config?: import("../../configs.js").PretrainedConfig;
18
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
19
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
20
+ model_file_name?: string;
21
+ }): Promise<string[]>;
22
+ //# sourceMappingURL=get_pipeline_files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_pipeline_files.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/get_pipeline_files.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,yCAVW,MAAM,WACN,MAAM,YAEd;IAA8D,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;IAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,UAAU,CAAC;IACpE,eAAe,GAAhC,MAAM;CACd,GAAU,OAAO,CAAC,MAAM,EAAE,CAAC,CA4B7B"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns the list of processor files that will be loaded for a model.
3
+ * Auto-detects if the model has a processor by checking if preprocessor_config.json exists.
4
+ *
5
+ * @param {string} modelId The model id (e.g., "Xenova/detr-resnet-50")
6
+ * @returns {Promise<string[]>} Array of processor file names (empty if no processor)
7
+ */
8
+ export function get_processor_files(modelId: string): Promise<string[]>;
9
+ //# sourceMappingURL=get_processor_files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_processor_files.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/get_processor_files.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,6CAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAW7B"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns the list of files that will be loaded for a tokenizer.
3
+ * Automatically detects whether the model has tokenizer files.
4
+ *
5
+ * @param {string} modelId The model id to check for tokenizer files
6
+ * @returns {Promise<string[]>} An array of file names that will be loaded
7
+ */
8
+ export function get_tokenizer_files(modelId: string): Promise<string[]>;
9
+ //# sourceMappingURL=get_tokenizer_files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_tokenizer_files.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/get_tokenizer_files.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,6CAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Quickly checks if a model is cached by verifying that `config.json` is present,
3
+ * then confirming all required files are cached.
4
+ * Returns a plain boolean — use `is_cached_files` if you need per-file detail.
5
+ *
6
+ * @param {string} modelId The model id (e.g., "Xenova/gpt2")
7
+ * @param {Object} [options] Optional parameters
8
+ * @param {string} [options.cache_dir] Custom cache directory
9
+ * @param {string} [options.revision] Model revision (default: 'main')
10
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] Pre-loaded config
11
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] Override dtype
12
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] Override device
13
+ * @returns {Promise<boolean>} Whether all required files are cached
14
+ */
15
+ export function is_cached(modelId: string, options?: {
16
+ cache_dir?: string;
17
+ revision?: string;
18
+ config?: import("../../configs.js").PretrainedConfig;
19
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
20
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
21
+ }): Promise<boolean>;
22
+ /**
23
+ * Checks if all files for a given model are already cached, with per-file detail.
24
+ * Automatically determines which files are needed using get_files().
25
+ *
26
+ * @param {string} modelId The model id (e.g., "Xenova/gpt2")
27
+ * @param {Object} [options] Optional parameters
28
+ * @param {string} [options.cache_dir] Custom cache directory
29
+ * @param {string} [options.revision] Model revision (default: 'main')
30
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] Pre-loaded config
31
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] Override dtype
32
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] Override device
33
+ * @returns {Promise<CacheCheckResult>} Object with allCached boolean and files array with cache status
34
+ */
35
+ export function is_cached_files(modelId: string, options?: {
36
+ cache_dir?: string;
37
+ revision?: string;
38
+ config?: import("../../configs.js").PretrainedConfig;
39
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
40
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
41
+ }): Promise<CacheCheckResult>;
42
+ /**
43
+ * Quickly checks if all files for a specific pipeline task are cached by verifying
44
+ * that `config.json` is present, then confirming all required files are cached.
45
+ * Returns a plain boolean — use `is_pipeline_cached_files` if you need per-file detail.
46
+ *
47
+ * @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
48
+ * @param {string} modelId - The model id (e.g., "Xenova/gpt2")
49
+ * @param {Object} [options] - Optional parameters
50
+ * @param {string} [options.cache_dir] - Custom cache directory
51
+ * @param {string} [options.revision] - Model revision (default: 'main')
52
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
53
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
54
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
55
+ * @returns {Promise<boolean>} Whether all required files are cached
56
+ */
57
+ export function is_pipeline_cached(task: string, modelId: string, options?: {
58
+ cache_dir?: string;
59
+ revision?: string;
60
+ config?: import("../../configs.js").PretrainedConfig;
61
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
62
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
63
+ }): Promise<boolean>;
64
+ /**
65
+ * Checks if all files for a specific pipeline task are already cached, with per-file detail.
66
+ * Automatically determines which components are needed based on the task.
67
+ *
68
+ * @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
69
+ * @param {string} modelId - The model id (e.g., "Xenova/gpt2")
70
+ * @param {Object} [options] - Optional parameters
71
+ * @param {string} [options.cache_dir] - Custom cache directory
72
+ * @param {string} [options.revision] - Model revision (default: 'main')
73
+ * @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
74
+ * @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
75
+ * @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
76
+ * @returns {Promise<CacheCheckResult>} Object with allCached boolean and files array with cache status
77
+ */
78
+ export function is_pipeline_cached_files(task: string, modelId: string, options?: {
79
+ cache_dir?: string;
80
+ revision?: string;
81
+ config?: import("../../configs.js").PretrainedConfig;
82
+ dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
83
+ device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
84
+ }): Promise<CacheCheckResult>;
85
+ export type FileCacheStatus = {
86
+ /**
87
+ * - The file path
88
+ */
89
+ file: string;
90
+ /**
91
+ * - Whether the file is cached
92
+ */
93
+ cached: boolean;
94
+ };
95
+ export type CacheCheckResult = {
96
+ /**
97
+ * - Whether all files are cached
98
+ */
99
+ allCached: boolean;
100
+ /**
101
+ * - Array of files with their cache status
102
+ */
103
+ files: FileCacheStatus[];
104
+ };
105
+ //# sourceMappingURL=is_cached.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_cached.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/is_cached.js"],"names":[],"mappings":"AA4DA;;;;;;;;;;;;;GAaG;AACH,mCATW,MAAM,YAEd;IAAyB,SAAS,GAA1B,MAAM;IACW,QAAQ,GAAzB,MAAM;IACgD,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;IAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IACiB,MAAM,GAAtG,OAAO,eA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