@huggingface/transformers 4.0.0-next.5 → 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.
- package/README.md +9 -4
- package/dist/ort-wasm-simd-threaded.jsep.mjs +23 -23
- package/dist/transformers.js +575 -418
- package/dist/transformers.min.js +17 -17
- package/dist/transformers.node.cjs +672 -499
- package/dist/transformers.node.min.cjs +18 -18
- package/dist/transformers.node.min.mjs +18 -18
- package/dist/transformers.node.mjs +651 -491
- package/dist/transformers.web.js +559 -402
- package/dist/transformers.web.min.js +18 -18
- package/package.json +3 -3
- package/src/backends/onnx.js +77 -58
- package/src/backends/utils/cacheWasm.js +22 -43
- package/src/configs.js +17 -5
- package/src/env.js +29 -6
- package/src/models/auto/modeling_auto.js +14 -1
- package/src/models/modeling_utils.js +35 -7
- package/src/models/models.js +5 -0
- package/src/models/olmo_hybrid/modeling_olmo_hybrid.js +5 -0
- package/src/models/qwen2_moe/modeling_qwen2_moe.js +5 -0
- package/src/models/qwen2_vl/modeling_qwen2_vl.js +37 -4
- package/src/models/qwen3_moe/modeling_qwen3_moe.js +5 -0
- package/src/models/qwen3_next/modeling_qwen3_next.js +5 -0
- package/src/models/qwen3_vl_moe/modeling_qwen3_vl_moe.js +3 -0
- package/src/models/registry.js +14 -4
- package/src/pipelines/index.js +2 -84
- package/src/pipelines.js +40 -77
- package/src/utils/cache/FileCache.js +128 -0
- package/src/utils/cache.js +3 -3
- package/src/utils/hub/{files.js → FileResponse.js} +0 -105
- package/src/utils/hub/utils.js +35 -1
- package/src/utils/hub.js +6 -5
- package/src/utils/image.js +12 -13
- package/src/utils/model_registry/ModelRegistry.js +70 -23
- package/src/utils/model_registry/get_model_files.js +12 -1
- package/src/utils/model_registry/get_pipeline_files.js +15 -24
- package/src/utils/model_registry/is_cached.js +81 -4
- package/types/backends/onnx.d.ts.map +1 -1
- package/types/backends/utils/cacheWasm.d.ts +3 -17
- package/types/backends/utils/cacheWasm.d.ts.map +1 -1
- package/types/configs.d.ts.map +1 -1
- package/types/env.d.ts +10 -3
- package/types/env.d.ts.map +1 -1
- package/types/models/auto/modeling_auto.d.ts +6 -0
- package/types/models/auto/modeling_auto.d.ts.map +1 -1
- package/types/models/modeling_utils.d.ts +13 -2
- package/types/models/modeling_utils.d.ts.map +1 -1
- package/types/models/models.d.ts +5 -0
- package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts +8 -0
- package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts.map +1 -0
- package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts +8 -0
- package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts.map +1 -0
- package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts.map +1 -1
- package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts +8 -0
- package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts.map +1 -0
- package/types/models/qwen3_next/modeling_qwen3_next.d.ts +8 -0
- package/types/models/qwen3_next/modeling_qwen3_next.d.ts.map +1 -0
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts +4 -0
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts.map +1 -0
- package/types/models/registry.d.ts +2 -1
- package/types/models/registry.d.ts.map +1 -1
- package/types/pipelines/index.d.ts +0 -34
- package/types/pipelines/index.d.ts.map +1 -1
- package/types/pipelines.d.ts.map +1 -1
- package/types/utils/cache/FileCache.d.ts +39 -0
- package/types/utils/cache/FileCache.d.ts.map +1 -0
- package/types/utils/cache.d.ts +4 -4
- package/types/utils/cache.d.ts.map +1 -1
- package/types/utils/hub/{files.d.ts → FileResponse.d.ts} +1 -38
- package/types/utils/hub/FileResponse.d.ts.map +1 -0
- package/types/utils/hub/utils.d.ts +17 -2
- package/types/utils/hub/utils.d.ts.map +1 -1
- package/types/utils/hub.d.ts +7 -7
- package/types/utils/hub.d.ts.map +1 -1
- package/types/utils/image.d.ts.map +1 -1
- package/types/utils/model_registry/ModelRegistry.d.ts +66 -6
- package/types/utils/model_registry/ModelRegistry.d.ts.map +1 -1
- package/types/utils/model_registry/get_model_files.d.ts.map +1 -1
- package/types/utils/model_registry/get_pipeline_files.d.ts +2 -1
- package/types/utils/model_registry/get_pipeline_files.d.ts.map +1 -1
- package/types/utils/model_registry/is_cached.d.ts +47 -4
- package/types/utils/model_registry/is_cached.d.ts.map +1 -1
- package/types/utils/hub/files.d.ts.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export const SUPPORTED_TASKS: Readonly<{
|
|
2
2
|
'text-classification': {
|
|
3
|
-
tokenizer: typeof AutoTokenizer;
|
|
4
3
|
pipeline: typeof TextClassificationPipeline;
|
|
5
4
|
model: typeof AutoModelForSequenceClassification;
|
|
6
5
|
default: {
|
|
@@ -9,7 +8,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
9
8
|
type: string;
|
|
10
9
|
};
|
|
11
10
|
'token-classification': {
|
|
12
|
-
tokenizer: typeof AutoTokenizer;
|
|
13
11
|
pipeline: typeof TokenClassificationPipeline;
|
|
14
12
|
model: typeof AutoModelForTokenClassification;
|
|
15
13
|
default: {
|
|
@@ -18,7 +16,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
18
16
|
type: string;
|
|
19
17
|
};
|
|
20
18
|
'question-answering': {
|
|
21
|
-
tokenizer: typeof AutoTokenizer;
|
|
22
19
|
pipeline: typeof QuestionAnsweringPipeline;
|
|
23
20
|
model: typeof AutoModelForQuestionAnswering;
|
|
24
21
|
default: {
|
|
@@ -27,7 +24,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
27
24
|
type: string;
|
|
28
25
|
};
|
|
29
26
|
'fill-mask': {
|
|
30
|
-
tokenizer: typeof AutoTokenizer;
|
|
31
27
|
pipeline: typeof FillMaskPipeline;
|
|
32
28
|
model: typeof AutoModelForMaskedLM;
|
|
33
29
|
default: {
|
|
@@ -37,7 +33,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
37
33
|
type: string;
|
|
38
34
|
};
|
|
39
35
|
summarization: {
|
|
40
|
-
tokenizer: typeof AutoTokenizer;
|
|
41
36
|
pipeline: typeof SummarizationPipeline;
|
|
42
37
|
model: typeof AutoModelForSeq2SeqLM;
|
|
43
38
|
default: {
|
|
@@ -46,7 +41,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
46
41
|
type: string;
|
|
47
42
|
};
|
|
48
43
|
translation: {
|
|
49
|
-
tokenizer: typeof AutoTokenizer;
|
|
50
44
|
pipeline: typeof TranslationPipeline;
|
|
51
45
|
model: typeof AutoModelForSeq2SeqLM;
|
|
52
46
|
default: {
|
|
@@ -55,7 +49,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
55
49
|
type: string;
|
|
56
50
|
};
|
|
57
51
|
'text2text-generation': {
|
|
58
|
-
tokenizer: typeof AutoTokenizer;
|
|
59
52
|
pipeline: typeof Text2TextGenerationPipeline;
|
|
60
53
|
model: typeof AutoModelForSeq2SeqLM;
|
|
61
54
|
default: {
|
|
@@ -64,7 +57,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
64
57
|
type: string;
|
|
65
58
|
};
|
|
66
59
|
'text-generation': {
|
|
67
|
-
tokenizer: typeof AutoTokenizer;
|
|
68
60
|
pipeline: typeof TextGenerationPipeline;
|
|
69
61
|
model: typeof AutoModelForCausalLM;
|
|
70
62
|
default: {
|
|
@@ -74,7 +66,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
74
66
|
type: string;
|
|
75
67
|
};
|
|
76
68
|
'zero-shot-classification': {
|
|
77
|
-
tokenizer: typeof AutoTokenizer;
|
|
78
69
|
pipeline: typeof ZeroShotClassificationPipeline;
|
|
79
70
|
model: typeof AutoModelForSequenceClassification;
|
|
80
71
|
default: {
|
|
@@ -85,37 +76,30 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
85
76
|
'audio-classification': {
|
|
86
77
|
pipeline: typeof AudioClassificationPipeline;
|
|
87
78
|
model: typeof AutoModelForAudioClassification;
|
|
88
|
-
processor: typeof AutoProcessor;
|
|
89
79
|
default: {
|
|
90
80
|
model: string;
|
|
91
81
|
};
|
|
92
82
|
type: string;
|
|
93
83
|
};
|
|
94
84
|
'zero-shot-audio-classification': {
|
|
95
|
-
tokenizer: typeof AutoTokenizer;
|
|
96
85
|
pipeline: typeof ZeroShotAudioClassificationPipeline;
|
|
97
86
|
model: typeof AutoModel;
|
|
98
|
-
processor: typeof AutoProcessor;
|
|
99
87
|
default: {
|
|
100
88
|
model: string;
|
|
101
89
|
};
|
|
102
90
|
type: string;
|
|
103
91
|
};
|
|
104
92
|
'automatic-speech-recognition': {
|
|
105
|
-
tokenizer: typeof AutoTokenizer;
|
|
106
93
|
pipeline: typeof AutomaticSpeechRecognitionPipeline;
|
|
107
94
|
model: (typeof AutoModelForSpeechSeq2Seq)[];
|
|
108
|
-
processor: typeof AutoProcessor;
|
|
109
95
|
default: {
|
|
110
96
|
model: string;
|
|
111
97
|
};
|
|
112
98
|
type: string;
|
|
113
99
|
};
|
|
114
100
|
'text-to-audio': {
|
|
115
|
-
tokenizer: typeof AutoTokenizer;
|
|
116
101
|
pipeline: typeof TextToAudioPipeline;
|
|
117
102
|
model: (typeof AutoModelForTextToSpectrogram)[];
|
|
118
|
-
processor: (typeof AutoProcessor)[];
|
|
119
103
|
default: {
|
|
120
104
|
model: string;
|
|
121
105
|
dtype: string;
|
|
@@ -123,10 +107,8 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
123
107
|
type: string;
|
|
124
108
|
};
|
|
125
109
|
'image-to-text': {
|
|
126
|
-
tokenizer: typeof AutoTokenizer;
|
|
127
110
|
pipeline: typeof ImageToTextPipeline;
|
|
128
111
|
model: typeof AutoModelForVision2Seq;
|
|
129
|
-
processor: typeof AutoProcessor;
|
|
130
112
|
default: {
|
|
131
113
|
model: string;
|
|
132
114
|
};
|
|
@@ -135,7 +117,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
135
117
|
'image-classification': {
|
|
136
118
|
pipeline: typeof ImageClassificationPipeline;
|
|
137
119
|
model: typeof AutoModelForImageClassification;
|
|
138
|
-
processor: typeof AutoProcessor;
|
|
139
120
|
default: {
|
|
140
121
|
model: string;
|
|
141
122
|
};
|
|
@@ -144,7 +125,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
144
125
|
'image-segmentation': {
|
|
145
126
|
pipeline: typeof ImageSegmentationPipeline;
|
|
146
127
|
model: (typeof AutoModelForImageSegmentation)[];
|
|
147
|
-
processor: typeof AutoProcessor;
|
|
148
128
|
default: {
|
|
149
129
|
model: string;
|
|
150
130
|
};
|
|
@@ -153,17 +133,14 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
153
133
|
'background-removal': {
|
|
154
134
|
pipeline: typeof BackgroundRemovalPipeline;
|
|
155
135
|
model: (typeof AutoModelForImageSegmentation)[];
|
|
156
|
-
processor: typeof AutoProcessor;
|
|
157
136
|
default: {
|
|
158
137
|
model: string;
|
|
159
138
|
};
|
|
160
139
|
type: string;
|
|
161
140
|
};
|
|
162
141
|
'zero-shot-image-classification': {
|
|
163
|
-
tokenizer: typeof AutoTokenizer;
|
|
164
142
|
pipeline: typeof ZeroShotImageClassificationPipeline;
|
|
165
143
|
model: typeof AutoModel;
|
|
166
|
-
processor: typeof AutoProcessor;
|
|
167
144
|
default: {
|
|
168
145
|
model: string;
|
|
169
146
|
};
|
|
@@ -172,27 +149,22 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
172
149
|
'object-detection': {
|
|
173
150
|
pipeline: typeof ObjectDetectionPipeline;
|
|
174
151
|
model: typeof AutoModelForObjectDetection;
|
|
175
|
-
processor: typeof AutoProcessor;
|
|
176
152
|
default: {
|
|
177
153
|
model: string;
|
|
178
154
|
};
|
|
179
155
|
type: string;
|
|
180
156
|
};
|
|
181
157
|
'zero-shot-object-detection': {
|
|
182
|
-
tokenizer: typeof AutoTokenizer;
|
|
183
158
|
pipeline: typeof ZeroShotObjectDetectionPipeline;
|
|
184
159
|
model: typeof AutoModelForZeroShotObjectDetection;
|
|
185
|
-
processor: typeof AutoProcessor;
|
|
186
160
|
default: {
|
|
187
161
|
model: string;
|
|
188
162
|
};
|
|
189
163
|
type: string;
|
|
190
164
|
};
|
|
191
165
|
'document-question-answering': {
|
|
192
|
-
tokenizer: typeof AutoTokenizer;
|
|
193
166
|
pipeline: typeof DocumentQuestionAnsweringPipeline;
|
|
194
167
|
model: typeof AutoModelForDocumentQuestionAnswering;
|
|
195
|
-
processor: typeof AutoProcessor;
|
|
196
168
|
default: {
|
|
197
169
|
model: string;
|
|
198
170
|
};
|
|
@@ -201,7 +173,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
201
173
|
'image-to-image': {
|
|
202
174
|
pipeline: typeof ImageToImagePipeline;
|
|
203
175
|
model: typeof AutoModelForImageToImage;
|
|
204
|
-
processor: typeof AutoProcessor;
|
|
205
176
|
default: {
|
|
206
177
|
model: string;
|
|
207
178
|
};
|
|
@@ -210,14 +181,12 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
210
181
|
'depth-estimation': {
|
|
211
182
|
pipeline: typeof DepthEstimationPipeline;
|
|
212
183
|
model: typeof AutoModelForDepthEstimation;
|
|
213
|
-
processor: typeof AutoProcessor;
|
|
214
184
|
default: {
|
|
215
185
|
model: string;
|
|
216
186
|
};
|
|
217
187
|
type: string;
|
|
218
188
|
};
|
|
219
189
|
'feature-extraction': {
|
|
220
|
-
tokenizer: typeof AutoTokenizer;
|
|
221
190
|
pipeline: typeof FeatureExtractionPipeline;
|
|
222
191
|
model: typeof AutoModel;
|
|
223
192
|
default: {
|
|
@@ -227,7 +196,6 @@ export const SUPPORTED_TASKS: Readonly<{
|
|
|
227
196
|
type: string;
|
|
228
197
|
};
|
|
229
198
|
'image-feature-extraction': {
|
|
230
|
-
processor: typeof AutoProcessor;
|
|
231
199
|
pipeline: typeof ImageFeatureExtractionPipeline;
|
|
232
200
|
model: (typeof AutoModel)[];
|
|
233
201
|
default: {
|
|
@@ -250,7 +218,6 @@ export type AliasType = keyof typeof TASK_ALIASES;
|
|
|
250
218
|
* All possible pipeline types.
|
|
251
219
|
*/
|
|
252
220
|
export type PipelineType = TaskType | AliasType;
|
|
253
|
-
import { AutoTokenizer } from '../models/auto/tokenization_auto.js';
|
|
254
221
|
import { TextClassificationPipeline } from './text-classification.js';
|
|
255
222
|
import { AutoModelForSequenceClassification } from '../models/auto/modeling_auto.js';
|
|
256
223
|
import { TokenClassificationPipeline } from './token-classification.js';
|
|
@@ -268,7 +235,6 @@ import { AutoModelForCausalLM } from '../models/auto/modeling_auto.js';
|
|
|
268
235
|
import { ZeroShotClassificationPipeline } from './zero-shot-classification.js';
|
|
269
236
|
import { AudioClassificationPipeline } from './audio-classification.js';
|
|
270
237
|
import { AutoModelForAudioClassification } from '../models/auto/modeling_auto.js';
|
|
271
|
-
import { AutoProcessor } from '../models/auto/processing_auto.js';
|
|
272
238
|
import { ZeroShotAudioClassificationPipeline } from './zero-shot-audio-classification.js';
|
|
273
239
|
import { AutoModel } from '../models/auto/modeling_auto.js';
|
|
274
240
|
import { AutomaticSpeechRecognitionPipeline } from './automatic-speech-recognition.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipelines/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipelines/index.js"],"names":[],"mappings":"AA2DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8MG;AAIH;;;;;;GASG;uBA+BU,MAAM,OAAO,eAAe;wBAC5B,MAAM,OAAO,YAAY;;;;2BACzB,QAAQ,GAAG,SAAS;2CAtRU,0BAA0B;mDAF9D,iCAAiC;4CAGI,2BAA2B;gDAHhE,iCAAiC;0CAIE,yBAAyB;8CAJ5D,iCAAiC;iCAKP,gBAAgB;qCAL1C,iCAAiC;sCAMF,oBAAoB;sCANnD,iCAAiC;oCAOJ,kBAAkB;4CACV,2BAA2B;uCAChC,sBAAsB;qCATtD,iCAAiC;+CAUO,+BAA+B;4CAClC,2BAA2B;gDAXhE,iCAAiC;oDAYY,qCAAqC;0BAZlF,iCAAiC;mDAaW,mCAAmC;0CAb/E,iCAAiC;oCAcJ,oBAAoB;8CAdjD,iCAAiC;oCAeJ,oBAAoB;uCAfjD,iCAAiC;4CAgBI,2BAA2B;gDAhBhE,iCAAiC;0CAiBE,yBAAyB;8CAjB5D,iCAAiC;0CAkBE,yBAAyB;oDACf,qCAAqC;wCACjD,uBAAuB;4CApBxD,iCAAiC;gDAqBQ,iCAAiC;oDArB1E,iCAAiC;kDAsBU,kCAAkC;sDAtB7E,iCAAiC;qCAuBH,qBAAqB;yCAvBnD,iCAAiC;wCAwBA,uBAAuB;4CAxBxD,iCAAiC;0CAyBE,yBAAyB;+CACpB,+BAA+B"}
|
package/types/pipelines.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipelines.d.ts","sourceRoot":"","sources":["../src/pipelines.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipelines.d.ts","sourceRoot":"","sources":["../src/pipelines.js"],"names":[],"mappings":"AAsDA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,yBA7B4B,CAAC,SAAf,YAAa,QAChB,CAAC,UAuBD,MAAM,gKACN,OAAO,gBAAgB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CA2IhC;uBAhLY,MAAM,OAAO,eAAe;wBAC5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B;oCAAtB,sBAAsB;4CAAtB,sBAAsB;uCAAtB,sBAAsB;+CAAtB,sBAAsB;4CAAtB,sBAAsB;oDAAtB,sBAAsB;mDAAtB,sBAAsB;oCAAtB,sBAAsB;oCAAtB,sBAAsB;4CAAtB,sBAAsB;0CAAtB,sBAAsB;0CAAtB,sBAAsB;oDAAtB,sBAAsB;wCAAtB,sBAAsB;gDAAtB,sBAAsB;kDAAtB,sBAAsB;qCAAtB,sBAAsB;wCAAtB,sBAAsB;0CAAtB,sBAAsB;+CAAtB,sBAAsB;gCAAtB,sBAAsB;6BAAtB,sBAAsB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File system cache implementation that implements the CacheInterface.
|
|
3
|
+
* Provides `match` and `put` methods compatible with the Web Cache API.
|
|
4
|
+
*/
|
|
5
|
+
export class FileCache {
|
|
6
|
+
/**
|
|
7
|
+
* Instantiate a `FileCache` object.
|
|
8
|
+
* @param {string} path
|
|
9
|
+
*/
|
|
10
|
+
constructor(path: string);
|
|
11
|
+
path: string;
|
|
12
|
+
/**
|
|
13
|
+
* Checks whether the given request is in the cache.
|
|
14
|
+
* @param {string} request
|
|
15
|
+
* @returns {Promise<FileResponse | undefined>}
|
|
16
|
+
*/
|
|
17
|
+
match(request: string): Promise<FileResponse | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Adds the given response to the cache.
|
|
20
|
+
* @param {string} request
|
|
21
|
+
* @param {Response} response
|
|
22
|
+
* @param {(data: {progress: number, loaded: number, total: number}) => void} [progress_callback] Optional.
|
|
23
|
+
* The function to call with progress updates
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
put(request: string, response: Response, progress_callback?: (data: {
|
|
27
|
+
progress: number;
|
|
28
|
+
loaded: number;
|
|
29
|
+
total: number;
|
|
30
|
+
}) => void): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Deletes the cache entry for the given request.
|
|
33
|
+
* @param {string} request
|
|
34
|
+
* @returns {Promise<boolean>} A Promise that resolves to `true` if the cache entry was deleted, `false` otherwise.
|
|
35
|
+
*/
|
|
36
|
+
delete(request: string): Promise<boolean>;
|
|
37
|
+
}
|
|
38
|
+
import { FileResponse } from '../hub/FileResponse.js';
|
|
39
|
+
//# sourceMappingURL=FileCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCache.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/FileCache.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH;IACI;;;OAGG;IACH,kBAFW,MAAM,EAIhB;IADG,aAAgB;IAGpB;;;;OAIG;IACH,eAHW,MAAM,GACJ,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAW7C;IAED;;;;;;;OAOG;IACH,aANW,MAAM,YACN,QAAQ,sBACR,CAAC,IAAI,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,KAAK,IAAI,GAE/D,OAAO,CAAC,IAAI,CAAC,CA0DzB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAY5B;CAOJ;6BA5H4B,wBAAwB"}
|
package/types/utils/cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} CacheInterface
|
|
3
|
-
* @property {(request: string) => Promise<Response|import('./hub/
|
|
3
|
+
* @property {(request: string) => Promise<Response|import('./hub/FileResponse.js').FileResponse|undefined|string>} match
|
|
4
4
|
* Checks if a request is in the cache and returns the cached response if found.
|
|
5
5
|
* @property {(request: string, response: Response, progress_callback?: (data: {progress: number, loaded: number, total: number}) => void) => Promise<void>} put
|
|
6
6
|
* Adds a response to the cache.
|
|
@@ -18,14 +18,14 @@ export function getCache(file_cache_dir?: string | null): Promise<CacheInterface
|
|
|
18
18
|
* Searches the cache for any of the provided names and returns the first match found.
|
|
19
19
|
* @param {CacheInterface} cache The cache to search
|
|
20
20
|
* @param {...string} names The names of the items to search for
|
|
21
|
-
* @returns {Promise<import('./hub/
|
|
21
|
+
* @returns {Promise<import('./hub/FileResponse.js').FileResponse|Response|undefined|string>} The item from the cache, or undefined if not found.
|
|
22
22
|
*/
|
|
23
|
-
export function tryCache(cache: CacheInterface, ...names: string[]): Promise<import("./hub/
|
|
23
|
+
export function tryCache(cache: CacheInterface, ...names: string[]): Promise<import("./hub/FileResponse.js").FileResponse | Response | undefined | string>;
|
|
24
24
|
export type CacheInterface = {
|
|
25
25
|
/**
|
|
26
26
|
* Checks if a request is in the cache and returns the cached response if found.
|
|
27
27
|
*/
|
|
28
|
-
match: (request: string) => Promise<Response | import("./hub/
|
|
28
|
+
match: (request: string) => Promise<Response | import("./hub/FileResponse.js").FileResponse | undefined | string>;
|
|
29
29
|
/**
|
|
30
30
|
* Adds a response to the cache.
|
|
31
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/utils/cache.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,0CAF0B,MAAM,GAAC,IAAI,GADxB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAiD1C;AAED;;;;;GAKG;AACH,gCAJW,cAAc,YACX,MAAM,EAAA,GACP,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/utils/cache.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,0CAF0B,MAAM,GAAC,IAAI,GADxB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAiD1C;AAED;;;;;GAKG;AACH,gCAJW,cAAc,YACX,MAAM,EAAA,GACP,OAAO,CAAC,OAAO,uBAAuB,EAAE,YAAY,GAAC,QAAQ,GAAC,SAAS,GAAC,MAAM,CAAC,CAY3F;;;;;WA9Ea,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAC,OAAO,uBAAuB,EAAE,YAAY,GAAC,SAAS,GAAC,MAAM,CAAC;;;;SAEpG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;;;;aAE7I,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC"}
|
|
@@ -51,41 +51,4 @@ export class FileResponse {
|
|
|
51
51
|
*/
|
|
52
52
|
json(): Promise<any>;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
* File system cache implementation that implements the CacheInterface.
|
|
56
|
-
* Provides `match` and `put` methods compatible with the Web Cache API.
|
|
57
|
-
*/
|
|
58
|
-
export class FileCache {
|
|
59
|
-
/**
|
|
60
|
-
* Instantiate a `FileCache` object.
|
|
61
|
-
* @param {string} path
|
|
62
|
-
*/
|
|
63
|
-
constructor(path: string);
|
|
64
|
-
path: string;
|
|
65
|
-
/**
|
|
66
|
-
* Checks whether the given request is in the cache.
|
|
67
|
-
* @param {string} request
|
|
68
|
-
* @returns {Promise<FileResponse | undefined>}
|
|
69
|
-
*/
|
|
70
|
-
match(request: string): Promise<FileResponse | undefined>;
|
|
71
|
-
/**
|
|
72
|
-
* Adds the given response to the cache.
|
|
73
|
-
* @param {string} request
|
|
74
|
-
* @param {Response} response
|
|
75
|
-
* @param {(data: {progress: number, loaded: number, total: number}) => void} [progress_callback] Optional.
|
|
76
|
-
* The function to call with progress updates
|
|
77
|
-
* @returns {Promise<void>}
|
|
78
|
-
*/
|
|
79
|
-
put(request: string, response: Response, progress_callback?: (data: {
|
|
80
|
-
progress: number;
|
|
81
|
-
loaded: number;
|
|
82
|
-
total: number;
|
|
83
|
-
}) => void): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Deletes the cache entry for the given request.
|
|
86
|
-
* @param {string} request
|
|
87
|
-
* @returns {Promise<boolean>} A Promise that resolves to `true` if the cache entry was deleted, `false` otherwise.
|
|
88
|
-
*/
|
|
89
|
-
delete(request: string): Promise<boolean>;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=files.d.ts.map
|
|
54
|
+
//# sourceMappingURL=FileResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileResponse.d.ts","sourceRoot":"","sources":["../../../src/utils/hub/FileResponse.js"],"names":[],"mappings":"AAiBA;IACI;;;OAGG;IACH,sBAFW,MAAM,EAgChB;IA7BG,iBAAwB;IACxB,iBAA4B;IAE5B,gBAAqC;IAEjC,eAAiB;IACjB,mBAAsB;IAQtB,0BASE;IAQV;;;;OAIG;IACH,qBAFa,IAAI,CAMhB;IAED;;;OAGG;IACH,SAFa,YAAY,CASxB;IAED;;;;;OAKG;IACH,eAHa,OAAO,CAAC,WAAW,CAAC,CAMhC;IAED;;;;;OAKG;IACH,QAHa,OAAO,CAAC,IAAI,CAAC,CAMzB;IAED;;;;;OAKG;IACH,QAHa,OAAO,CAAC,MAAM,CAAC,CAK3B;IAED;;;;;;OAMG;IACH,QAHa,OAAO,KAAQ,CAK3B;CACJ"}
|
|
@@ -33,14 +33,29 @@ export function handleError(status: number, remoteURL: string, fatal: boolean):
|
|
|
33
33
|
/**
|
|
34
34
|
* Read and track progress when reading a Response object
|
|
35
35
|
*
|
|
36
|
-
* @param {Response|import('./
|
|
36
|
+
* @param {Response|import('./FileResponse.js').FileResponse} response The Response object to read
|
|
37
37
|
* @param {(data: {progress: number, loaded: number, total: number}) => void} progress_callback The function to call with progress updates
|
|
38
38
|
* @param {number} [expectedSize] The expected size of the file (used when content-length header is missing)
|
|
39
39
|
* @returns {Promise<Uint8Array>} A Promise that resolves with the Uint8Array buffer
|
|
40
40
|
*/
|
|
41
|
-
export function readResponse(response: Response | import("./
|
|
41
|
+
export function readResponse(response: Response | import("./FileResponse.js").FileResponse, progress_callback: (data: {
|
|
42
42
|
progress: number;
|
|
43
43
|
loaded: number;
|
|
44
44
|
total: number;
|
|
45
45
|
}) => void, expectedSize?: number): Promise<Uint8Array>;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the given URL is a blob URL (created via URL.createObjectURL).
|
|
48
|
+
* Blob URLs should not be cached as they are temporary in-memory references.
|
|
49
|
+
* @param {string} url - The URL to check.
|
|
50
|
+
* @returns {boolean} True if the URL is a blob URL, false otherwise.
|
|
51
|
+
*/
|
|
52
|
+
export function isBlobURL(url: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Converts any URL to an absolute URL if needed.
|
|
55
|
+
* If the URL is already absolute (http://, https://, or blob:), returns it unchanged (handled by new URL(...)).
|
|
56
|
+
* Otherwise, resolves it relative to the current page location (browser) or module location (Node/Bun/Deno).
|
|
57
|
+
* @param {string} url - The URL to convert (can be relative or absolute).
|
|
58
|
+
* @returns {string} The absolute URL.
|
|
59
|
+
*/
|
|
60
|
+
export function toAbsoluteURL(url: string): string;
|
|
46
61
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils/hub/utils.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,mCAHc,MAAM,EAAA,GACP,MAAM,CAclB;AAED;;;;;;GAMG;AACH,mCALW,MAAM,GAAC,GAAG,cACV,MAAM,EAAE,eACR,MAAM,EAAE,GACN,OAAO,CAgBnB;AAED;;;;;;GAMG;AACH,yCAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;;GAOG;AACH,oCANW,MAAM,aACN,MAAM,SACN,OAAO,GACL,IAAI,CAYhB;AAED;;;;;;;GAOG;AACH,uCALW,QAAQ,GAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils/hub/utils.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,mCAHc,MAAM,EAAA,GACP,MAAM,CAclB;AAED;;;;;;GAMG;AACH,mCALW,MAAM,GAAC,GAAG,cACV,MAAM,EAAE,eACR,MAAM,EAAE,GACN,OAAO,CAgBnB;AAED;;;;;;GAMG;AACH,yCAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;;GAOG;AACH,oCANW,MAAM,aACN,MAAM,SACN,OAAO,GACL,IAAI,CAYhB;AAED;;;;;;;GAOG;AACH,uCALW,QAAQ,GAAC,OAAO,mBAAmB,EAAE,YAAY,qBACjD,CAAC,IAAI,EAAE;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,KAAK,IAAI,iBACjE,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,CAgD/B;AAED;;;;;GAKG;AACH,+BAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;;GAMG;AACH,mCAHW,MAAM,GACJ,MAAM,CAiBlB"}
|
package/types/utils/hub.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @typedef {Object} ModelSpecificPretrainedOptions Options for loading a pretrained model.
|
|
22
22
|
* @property {string} [subfolder='onnx'] In case the relevant files are located inside a subfolder of the model repo on huggingface.co,
|
|
23
23
|
* you can specify the folder name here.
|
|
24
|
-
* @property {string} [model_file_name=null] If specified, load the model with this name (excluding the .onnx
|
|
24
|
+
* @property {string} [model_file_name=null] If specified, load the model with this name (excluding the dtype and .onnx suffixes). Currently only valid for encoder- or decoder-only models.
|
|
25
25
|
* @property {import("./devices.js").DeviceType|Record<string, import("./devices.js").DeviceType>} [device=null] The device to run the model on. If not specified, the device will be chosen from the environment settings.
|
|
26
26
|
* @property {import("./dtypes.js").DataType|Record<string, import("./dtypes.js").DataType>} [dtype=null] The data type to use for the model. If not specified, the data type will be chosen from the environment settings.
|
|
27
27
|
* @property {ExternalData|Record<string, ExternalData>} [use_external_data_format=false] Whether to load the model using the external data format (used for models >= 2GB in size).
|
|
@@ -72,10 +72,10 @@ export function buildResourcePaths(path_or_repo_id: string, filename: string, op
|
|
|
72
72
|
* @param {import('./cache.js').CacheInterface | null} cache The cache instance to check.
|
|
73
73
|
* @param {string} localPath The local path to try first.
|
|
74
74
|
* @param {string} proposedCacheKey The proposed cache key to try second.
|
|
75
|
-
* @returns {Promise<Response|import('./hub/
|
|
75
|
+
* @returns {Promise<Response|import('./hub/FileResponse.js').FileResponse|undefined|string>}
|
|
76
76
|
* The cached response if found, undefined otherwise.
|
|
77
77
|
*/
|
|
78
|
-
export function checkCachedResource(cache: import("./cache.js").CacheInterface | null, localPath: string, proposedCacheKey: string): Promise<Response | import("./hub/
|
|
78
|
+
export function checkCachedResource(cache: import("./cache.js").CacheInterface | null, localPath: string, proposedCacheKey: string): Promise<Response | import("./hub/FileResponse.js").FileResponse | undefined | string>;
|
|
79
79
|
/**
|
|
80
80
|
* Stores a resource in the cache.
|
|
81
81
|
*
|
|
@@ -83,12 +83,12 @@ export function checkCachedResource(cache: import("./cache.js").CacheInterface |
|
|
|
83
83
|
* @param {string} filename The name of the file to cache.
|
|
84
84
|
* @param {import('./cache.js').CacheInterface} cache The cache instance to store in.
|
|
85
85
|
* @param {string} cacheKey The cache key to use.
|
|
86
|
-
* @param {Response|import('./hub/
|
|
86
|
+
* @param {Response|import('./hub/FileResponse.js').FileResponse} response The response to cache.
|
|
87
87
|
* @param {Uint8Array} [result] The result buffer if already read.
|
|
88
88
|
* @param {PretrainedOptions} [options] Options containing progress callback and context for progress updates.
|
|
89
89
|
* @returns {Promise<void>}
|
|
90
90
|
*/
|
|
91
|
-
export function storeCachedResource(path_or_repo_id: string, filename: string, cache: import("./cache.js").CacheInterface, cacheKey: string, response: Response | import("./hub/
|
|
91
|
+
export function storeCachedResource(path_or_repo_id: string, filename: string, cache: import("./cache.js").CacheInterface, cacheKey: string, response: Response | import("./hub/FileResponse.js").FileResponse, result?: Uint8Array, options?: PretrainedOptions): Promise<void>;
|
|
92
92
|
/**
|
|
93
93
|
* Loads a resource file from local or remote sources.
|
|
94
94
|
*
|
|
@@ -190,7 +190,7 @@ export type ModelSpecificPretrainedOptions = {
|
|
|
190
190
|
*/
|
|
191
191
|
subfolder?: string;
|
|
192
192
|
/**
|
|
193
|
-
* If specified, load the model with this name (excluding the .onnx
|
|
193
|
+
* If specified, load the model with this name (excluding the dtype and .onnx suffixes). Currently only valid for encoder- or decoder-only models.
|
|
194
194
|
*/
|
|
195
195
|
model_file_name?: string;
|
|
196
196
|
/**
|
|
@@ -214,5 +214,5 @@ export type ModelSpecificPretrainedOptions = {
|
|
|
214
214
|
* Options for loading a pretrained model.
|
|
215
215
|
*/
|
|
216
216
|
export type PretrainedModelOptions = PretrainedOptions & ModelSpecificPretrainedOptions;
|
|
217
|
-
import { FileResponse } from './hub/
|
|
217
|
+
import { FileResponse } from './hub/FileResponse.js';
|
|
218
218
|
//# sourceMappingURL=hub.d.ts.map
|
package/types/utils/hub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../src/utils/hub.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../src/utils/hub.js"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;GASG;AAEH;;GAEG;AAEH;;;;;GAKG;AACH,mCAHW,GAAG,GAAC,MAAM,GACR,OAAO,CAAC,YAAY,GAAC,QAAQ,CAAC,CAgB1C;AAED;;;;;;;GAOG;AACH,2CAHW,GAAG,GAAC,MAAM,GACR,OAAO,CA4BnB;AAED;;;;;;;;;;;;GAYG;AACH,oDATW,MAAM,YAGN,MAAM,YACN,iBAAiB,UACjB,OAAO,YAAY,EAAE,cAA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,EAAE,gBAAgB;;;;gBAGxC,MAAM;;;;uBACN,OAAO;;;;;;eACP,MAAM;;;;;;;;;;gBAON,MAAM;;;;sBAEN,MAAM;;;;aACN,OAAO,cAAc,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,UAAU,CAAC;;;;YACnF,OAAO,aAAa,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,aAAa,EAAE,QAAQ,CAAC;;;;+BAC7E,YAAY,GAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;;;;sBACzC,OAAO,oBAAoB,EAAE,gBAAgB,CAAC,cAAc;;;;;qCAI7D,iBAAiB,GAAG,8BAA8B;6BA1ClC,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/utils/image.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/utils/image.js"],"names":[],"mappings":"AAyEA;IAuBI;;;;;;;;;;;;;;;OAeG;IACH,mBAdW,QAAQ,GAAC,MAAM,GAAC,GAAG,GAAC,IAAI,GAAC,iBAAiB,GAAC,eAAe,GACxD,OAAO,CAAC,QAAQ,CAAC,CA4B7B;IAED;;;;OAIG;IACH,0BAHW,iBAAiB,GAAC,eAAe,GAC/B,QAAQ,CAYpB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GAAC,GAAG,GACR,OAAO,CAAC,QAAQ,CAAC,CAS7B;IAED;;;;OAIG;IACH,sBAHW,IAAI,GACF,OAAO,CAAC,QAAQ,CAAC,CAmB7B;IAED;;;OAGG;IACH,0BAFW,MAAM,qCA0BhB;IA1ID;;;;;;OAMG;IACH,kBALW,iBAAiB,GAAC,UAAU,SAC5B,MAAM,UACN,MAAM,YACN,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,EAOjB;IAJG,uEAAgB;IAChB,cAAkB;IAClB,eAAoB;IACpB,wBAAwB;IAG5B;;;OAGG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,CAAC,CAI5B;IAwHD;;;OAGG;IACH,aAFa,QAAQ,CAuBpB;IAED;;;OAGG;IACH,OAFa,QAAQ,CA4BpB;IAED;;;OAGG;IACH,QAFa,QAAQ,CA+BpB;IAED;;;;;;;OAOG;IACH,eANW,QAAQ,GACN,QAAQ,CAoCpB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,UACN,MAAM,iBAEd;QAAqC,QAAQ,GAArC,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,MAAM;KAC1B,GAAU,OAAO,CAAC,QAAQ,CAAC,CAsF7B;IAED,oEAoCC;IAED,uEAkDC;IAED,6DAmHC;IAED,sDAOC;IAED,0CAYC;IAED,gBAiBC;IAED;;;;;;OAMG;IACH,SAFa,QAAQ,EAAE,CAoBtB;IAED;;;;;;;OAOG;IACH,gBAQC;IAED;;;OAGG;IACH,SAFa,QAAQ,CAIpB;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACJ,QAAQ,CAmBpB;IAED;;;;OAIG;IACH,WAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAqBzB;IAED;;;OAGG;IACH,WAFa,OAAO,OAAO,EAAE,KAAK,CAcjC;CACJ;AAED;;GAEG;AACH,6BAAuD;uBAryBhC,aAAa"}
|
|
@@ -95,24 +95,83 @@ export class ModelRegistry {
|
|
|
95
95
|
*/
|
|
96
96
|
static get_processor_files(modelId: string): Promise<string[]>;
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
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.
|
|
99
101
|
*
|
|
100
102
|
* @param {string} modelId - The model id
|
|
101
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
|
|
102
131
|
* @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype=null] - Override dtype
|
|
103
132
|
* @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device=null] - Override device
|
|
104
133
|
* @returns {Promise<import('./is_cached.js').CacheCheckResult>} Object with allCached boolean and files array with cache status
|
|
105
134
|
*
|
|
106
135
|
* @example
|
|
107
|
-
* const status = await ModelRegistry.
|
|
136
|
+
* const status = await ModelRegistry.is_cached_files('onnx-community/bert-base-uncased-ONNX');
|
|
108
137
|
* console.log(status.allCached); // true or false
|
|
138
|
+
* console.log(status.files); // [{ file: 'config.json', cached: true }, ...]
|
|
109
139
|
*/
|
|
110
|
-
static
|
|
140
|
+
static is_cached_files(modelId: string, options?: {
|
|
141
|
+
cache_dir?: string;
|
|
142
|
+
revision?: string;
|
|
143
|
+
config?: import("../../configs.js").PretrainedConfig;
|
|
111
144
|
dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
|
|
112
145
|
device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
|
|
113
146
|
}): Promise<import("./is_cached.js").CacheCheckResult>;
|
|
114
147
|
/**
|
|
115
|
-
*
|
|
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.
|
|
116
175
|
* Automatically determines which components are needed based on the task.
|
|
117
176
|
*
|
|
118
177
|
* @param {string} task - The pipeline task (e.g., "text-generation", "background-removal")
|
|
@@ -126,10 +185,11 @@ export class ModelRegistry {
|
|
|
126
185
|
* @returns {Promise<import('./is_cached.js').CacheCheckResult>} Object with allCached boolean and files array with cache status
|
|
127
186
|
*
|
|
128
187
|
* @example
|
|
129
|
-
* const status = await ModelRegistry.
|
|
188
|
+
* const status = await ModelRegistry.is_pipeline_cached_files('text-generation', 'onnx-community/gpt2-ONNX');
|
|
130
189
|
* console.log(status.allCached); // true or false
|
|
190
|
+
* console.log(status.files); // [{ file: 'config.json', cached: true }, ...]
|
|
131
191
|
*/
|
|
132
|
-
static
|
|
192
|
+
static is_pipeline_cached_files(task: string, modelId: string, options?: {
|
|
133
193
|
cache_dir?: string;
|
|
134
194
|
revision?: string;
|
|
135
195
|
config?: import("../../configs.js").PretrainedConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelRegistry.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/ModelRegistry.js"],"names":[],"mappings":"
|
|
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;Q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AO;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"}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get all files needed for a specific pipeline task.
|
|
3
|
-
* Automatically
|
|
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).
|
|
4
5
|
*
|
|
5
6
|
* @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
|
|
6
7
|
* @param {string} modelId - The model id (e.g., "Xenova/bert-base-uncased")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_pipeline_files.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/get_pipeline_files.js"],"names":[],"mappings":"
|
|
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"}
|