@huggingface/inference 4.13.9 → 4.13.11
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/dist/commonjs/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/commonjs/lib/getProviderHelper.js +8 -4
- package/dist/commonjs/lib/makeRequestOptions.d.ts +2 -1
- package/dist/commonjs/lib/makeRequestOptions.d.ts.map +1 -1
- package/dist/commonjs/lib/makeRequestOptions.js +4 -2
- package/dist/commonjs/package.d.ts +1 -1
- package/dist/commonjs/package.d.ts.map +1 -1
- package/dist/commonjs/package.js +1 -1
- package/dist/commonjs/providers/fal-ai.d.ts +13 -3
- package/dist/commonjs/providers/fal-ai.d.ts.map +1 -1
- package/dist/commonjs/providers/fal-ai.js +49 -2
- package/dist/commonjs/providers/hf-inference.d.ts +3 -2
- package/dist/commonjs/providers/hf-inference.d.ts.map +1 -1
- package/dist/commonjs/providers/hf-inference.js +14 -8
- package/dist/commonjs/providers/hyperbolic.d.ts +2 -2
- package/dist/commonjs/providers/hyperbolic.d.ts.map +1 -1
- package/dist/commonjs/providers/hyperbolic.js +4 -1
- package/dist/commonjs/providers/nebius.d.ts +5 -4
- package/dist/commonjs/providers/nebius.d.ts.map +1 -1
- package/dist/commonjs/providers/nebius.js +11 -8
- package/dist/commonjs/providers/nscale.d.ts +2 -2
- package/dist/commonjs/providers/nscale.d.ts.map +1 -1
- package/dist/commonjs/providers/nscale.js +4 -1
- package/dist/commonjs/providers/providerHelper.d.ts +3 -3
- package/dist/commonjs/providers/providerHelper.d.ts.map +1 -1
- package/dist/commonjs/providers/providerHelper.js +3 -0
- package/dist/commonjs/providers/replicate.d.ts +2 -2
- package/dist/commonjs/providers/replicate.d.ts.map +1 -1
- package/dist/commonjs/providers/replicate.js +11 -3
- package/dist/commonjs/providers/together.d.ts +5 -4
- package/dist/commonjs/providers/together.d.ts.map +1 -1
- package/dist/commonjs/providers/together.js +11 -8
- package/dist/commonjs/providers/wavespeed.d.ts +14 -4
- package/dist/commonjs/providers/wavespeed.d.ts.map +1 -1
- package/dist/commonjs/providers/wavespeed.js +30 -2
- package/dist/commonjs/providers/zai-org.d.ts +2 -2
- package/dist/commonjs/providers/zai-org.d.ts.map +1 -1
- package/dist/commonjs/providers/zai-org.js +3 -1
- package/dist/commonjs/snippets/getInferenceSnippets.js +11 -20
- package/dist/commonjs/tasks/cv/textToImage.d.ts +5 -2
- package/dist/commonjs/tasks/cv/textToImage.d.ts.map +1 -1
- package/dist/commonjs/types.d.ts +4 -0
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/utils/dataUrlFromBlob.d.ts +2 -0
- package/dist/commonjs/utils/dataUrlFromBlob.d.ts.map +1 -0
- package/dist/commonjs/utils/dataUrlFromBlob.js +9 -0
- package/dist/esm/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/esm/lib/getProviderHelper.js +8 -4
- package/dist/esm/lib/makeRequestOptions.d.ts +2 -1
- package/dist/esm/lib/makeRequestOptions.d.ts.map +1 -1
- package/dist/esm/lib/makeRequestOptions.js +4 -2
- package/dist/esm/package.d.ts +1 -1
- package/dist/esm/package.d.ts.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/esm/providers/fal-ai.d.ts +13 -3
- package/dist/esm/providers/fal-ai.d.ts.map +1 -1
- package/dist/esm/providers/fal-ai.js +46 -1
- package/dist/esm/providers/hf-inference.d.ts +3 -2
- package/dist/esm/providers/hf-inference.d.ts.map +1 -1
- package/dist/esm/providers/hf-inference.js +15 -9
- package/dist/esm/providers/hyperbolic.d.ts +2 -2
- package/dist/esm/providers/hyperbolic.d.ts.map +1 -1
- package/dist/esm/providers/hyperbolic.js +5 -2
- package/dist/esm/providers/nebius.d.ts +5 -4
- package/dist/esm/providers/nebius.d.ts.map +1 -1
- package/dist/esm/providers/nebius.js +11 -8
- package/dist/esm/providers/nscale.d.ts +2 -2
- package/dist/esm/providers/nscale.d.ts.map +1 -1
- package/dist/esm/providers/nscale.js +5 -2
- package/dist/esm/providers/providerHelper.d.ts +3 -3
- package/dist/esm/providers/providerHelper.d.ts.map +1 -1
- package/dist/esm/providers/providerHelper.js +3 -0
- package/dist/esm/providers/replicate.d.ts +2 -2
- package/dist/esm/providers/replicate.d.ts.map +1 -1
- package/dist/esm/providers/replicate.js +11 -3
- package/dist/esm/providers/together.d.ts +5 -4
- package/dist/esm/providers/together.d.ts.map +1 -1
- package/dist/esm/providers/together.js +11 -8
- package/dist/esm/providers/wavespeed.d.ts +14 -4
- package/dist/esm/providers/wavespeed.d.ts.map +1 -1
- package/dist/esm/providers/wavespeed.js +27 -1
- package/dist/esm/providers/zai-org.d.ts +2 -2
- package/dist/esm/providers/zai-org.d.ts.map +1 -1
- package/dist/esm/providers/zai-org.js +3 -1
- package/dist/esm/snippets/getInferenceSnippets.js +11 -20
- package/dist/esm/tasks/cv/textToImage.d.ts +5 -2
- package/dist/esm/tasks/cv/textToImage.d.ts.map +1 -1
- package/dist/esm/types.d.ts +4 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils/dataUrlFromBlob.d.ts +2 -0
- package/dist/esm/utils/dataUrlFromBlob.d.ts.map +1 -0
- package/dist/esm/utils/dataUrlFromBlob.js +6 -0
- package/package.json +34 -34
- package/src/InferenceClient.ts +2 -2
- package/src/errors.ts +1 -1
- package/src/lib/getDefaultTask.ts +1 -1
- package/src/lib/getInferenceProviderMapping.ts +11 -11
- package/src/lib/getProviderHelper.ts +45 -41
- package/src/lib/makeRequestOptions.ts +17 -14
- package/src/package.ts +1 -1
- package/src/providers/black-forest-labs.ts +3 -3
- package/src/providers/fal-ai.ts +92 -36
- package/src/providers/featherless-ai.ts +1 -1
- package/src/providers/hf-inference.ts +66 -57
- package/src/providers/hyperbolic.ts +10 -5
- package/src/providers/nebius.ts +19 -13
- package/src/providers/novita.ts +7 -7
- package/src/providers/nscale.ts +9 -4
- package/src/providers/ovhcloud.ts +1 -1
- package/src/providers/providerHelper.ts +19 -8
- package/src/providers/replicate.ts +14 -6
- package/src/providers/sambanova.ts +1 -1
- package/src/providers/together.ts +19 -13
- package/src/providers/wavespeed.ts +56 -12
- package/src/providers/zai-org.ts +11 -9
- package/src/snippets/getInferenceSnippets.ts +26 -26
- package/src/tasks/audio/audioClassification.ts +1 -1
- package/src/tasks/audio/automaticSpeechRecognition.ts +1 -1
- package/src/tasks/audio/utils.ts +1 -1
- package/src/tasks/custom/request.ts +2 -2
- package/src/tasks/custom/streamingRequest.ts +2 -2
- package/src/tasks/cv/imageClassification.ts +1 -1
- package/src/tasks/cv/imageSegmentation.ts +1 -1
- package/src/tasks/cv/textToImage.ts +10 -6
- package/src/tasks/cv/textToVideo.ts +1 -1
- package/src/tasks/cv/zeroShotImageClassification.ts +3 -3
- package/src/tasks/multimodal/documentQuestionAnswering.ts +2 -2
- package/src/tasks/multimodal/visualQuestionAnswering.ts +1 -1
- package/src/tasks/nlp/chatCompletion.ts +1 -1
- package/src/tasks/nlp/chatCompletionStream.ts +1 -1
- package/src/tasks/nlp/featureExtraction.ts +1 -1
- package/src/tasks/nlp/questionAnswering.ts +2 -2
- package/src/tasks/nlp/sentenceSimilarity.ts +1 -1
- package/src/tasks/nlp/tableQuestionAnswering.ts +2 -2
- package/src/tasks/nlp/textClassification.ts +1 -1
- package/src/tasks/nlp/textGeneration.ts +1 -1
- package/src/tasks/nlp/textGenerationStream.ts +1 -1
- package/src/tasks/nlp/tokenClassification.ts +2 -2
- package/src/tasks/nlp/zeroShotClassification.ts +2 -2
- package/src/tasks/tabular/tabularClassification.ts +1 -1
- package/src/tasks/tabular/tabularRegression.ts +1 -1
- package/src/types.ts +5 -0
- package/src/utils/dataUrlFromBlob.ts +7 -0
- package/src/utils/pick.ts +1 -1
- package/src/utils/request.ts +20 -20
- package/src/utils/typedEntries.ts +1 -1
|
@@ -36,9 +36,9 @@ import type {
|
|
|
36
36
|
ZeroShotImageClassificationOutput,
|
|
37
37
|
} from "@huggingface/tasks";
|
|
38
38
|
import { HF_ROUTER_URL } from "../config.js";
|
|
39
|
-
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
39
|
+
import { InferenceClientInputError, InferenceClientProviderOutputError } from "../errors.js";
|
|
40
40
|
import type { TabularClassificationOutput } from "../tasks/tabular/tabularClassification.js";
|
|
41
|
-
import type { BodyParams, RequestArgs, UrlParams } from "../types.js";
|
|
41
|
+
import type { BodyParams, OutputType, RequestArgs, UrlParams } from "../types.js";
|
|
42
42
|
import { toArray } from "../utils/toArray.js";
|
|
43
43
|
import type {
|
|
44
44
|
AudioClassificationTaskHelper,
|
|
@@ -73,6 +73,7 @@ import type {
|
|
|
73
73
|
|
|
74
74
|
import { TaskProviderHelper } from "./providerHelper.js";
|
|
75
75
|
import { base64FromBytes } from "../utils/base64FromBytes.js";
|
|
76
|
+
import { dataUrlFromBlob } from "../utils/dataUrlFromBlob.js";
|
|
76
77
|
import type { ImageToImageArgs } from "../tasks/cv/imageToImage.js";
|
|
77
78
|
import type { AutomaticSpeechRecognitionArgs } from "../tasks/audio/automaticSpeechRecognition.js";
|
|
78
79
|
import { omit } from "../utils/omit.js";
|
|
@@ -123,15 +124,24 @@ export class HFInferenceTask extends TaskProviderHelper {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
export class HFInferenceTextToImageTask extends HFInferenceTask implements TextToImageTaskHelper {
|
|
127
|
+
override preparePayload(params: BodyParams): Record<string, unknown> {
|
|
128
|
+
if (params.outputType === "url") {
|
|
129
|
+
throw new InferenceClientInputError(
|
|
130
|
+
"hf-inference provider does not support URL output. Use outputType 'blob', 'dataUrl' or 'json' instead.",
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return params.args;
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
override async getResponse(
|
|
127
137
|
response: Base64ImageGeneration | OutputUrlImageGeneration,
|
|
128
138
|
url?: string,
|
|
129
139
|
headers?: HeadersInit,
|
|
130
|
-
outputType?:
|
|
140
|
+
outputType?: OutputType,
|
|
131
141
|
): Promise<string | Blob | Record<string, unknown>> {
|
|
132
142
|
if (!response) {
|
|
133
143
|
throw new InferenceClientProviderOutputError(
|
|
134
|
-
"Received malformed response from HF-Inference text-to-image API: response is undefined"
|
|
144
|
+
"Received malformed response from HF-Inference text-to-image API: response is undefined",
|
|
135
145
|
);
|
|
136
146
|
}
|
|
137
147
|
if (typeof response == "object") {
|
|
@@ -140,30 +150,29 @@ export class HFInferenceTextToImageTask extends HFInferenceTask implements TextT
|
|
|
140
150
|
}
|
|
141
151
|
if ("data" in response && Array.isArray(response.data) && response.data[0].b64_json) {
|
|
142
152
|
const base64Data = response.data[0].b64_json;
|
|
143
|
-
if (outputType === "
|
|
153
|
+
if (outputType === "dataUrl") {
|
|
144
154
|
return `data:image/jpeg;base64,${base64Data}`;
|
|
145
155
|
}
|
|
146
156
|
const base64Response = await fetch(`data:image/jpeg;base64,${base64Data}`);
|
|
147
157
|
return await base64Response.blob();
|
|
148
158
|
}
|
|
149
159
|
if ("output" in response && Array.isArray(response.output)) {
|
|
150
|
-
if (outputType === "url") {
|
|
151
|
-
return response.output[0];
|
|
152
|
-
}
|
|
153
160
|
const urlResponse = await fetch(response.output[0]);
|
|
154
161
|
const blob = await urlResponse.blob();
|
|
155
|
-
return blob;
|
|
162
|
+
return outputType === "dataUrl" ? dataUrlFromBlob(blob) : blob;
|
|
156
163
|
}
|
|
157
164
|
}
|
|
158
165
|
if (response instanceof Blob) {
|
|
159
|
-
if (outputType === "
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
if (outputType === "dataUrl") {
|
|
167
|
+
return dataUrlFromBlob(response);
|
|
168
|
+
}
|
|
169
|
+
if (outputType === "json") {
|
|
170
|
+
return { output: await dataUrlFromBlob(response) };
|
|
162
171
|
}
|
|
163
172
|
return response;
|
|
164
173
|
}
|
|
165
174
|
throw new InferenceClientProviderOutputError(
|
|
166
|
-
"Received malformed response from HF-Inference text-to-image API: expected a Blob"
|
|
175
|
+
"Received malformed response from HF-Inference text-to-image API: expected a Blob",
|
|
167
176
|
);
|
|
168
177
|
}
|
|
169
178
|
}
|
|
@@ -206,7 +215,7 @@ export class HFInferenceTextGenerationTask extends HFInferenceTask implements Te
|
|
|
206
215
|
return (res as TextGenerationOutput[])?.[0];
|
|
207
216
|
}
|
|
208
217
|
throw new InferenceClientProviderOutputError(
|
|
209
|
-
"Received malformed response from HF-Inference text generation API: expected Array<{generated_text: string}>"
|
|
218
|
+
"Received malformed response from HF-Inference text generation API: expected Array<{generated_text: string}>",
|
|
210
219
|
);
|
|
211
220
|
}
|
|
212
221
|
}
|
|
@@ -217,13 +226,13 @@ export class HFInferenceAudioClassificationTask extends HFInferenceTask implemen
|
|
|
217
226
|
Array.isArray(response) &&
|
|
218
227
|
response.every(
|
|
219
228
|
(x): x is { label: string; score: number } =>
|
|
220
|
-
typeof x === "object" && x !== null && typeof x.label === "string" && typeof x.score === "number"
|
|
229
|
+
typeof x === "object" && x !== null && typeof x.label === "string" && typeof x.score === "number",
|
|
221
230
|
)
|
|
222
231
|
) {
|
|
223
232
|
return response;
|
|
224
233
|
}
|
|
225
234
|
throw new InferenceClientProviderOutputError(
|
|
226
|
-
"Received malformed response from HF-Inference audio-classification API: expected Array<{label: string, score: number}> but received different format"
|
|
235
|
+
"Received malformed response from HF-Inference audio-classification API: expected Array<{label: string, score: number}> but received different format",
|
|
227
236
|
);
|
|
228
237
|
}
|
|
229
238
|
}
|
|
@@ -242,7 +251,7 @@ export class HFInferenceAutomaticSpeechRecognitionTask
|
|
|
242
251
|
: {
|
|
243
252
|
...omit(args, "inputs"),
|
|
244
253
|
data: args.inputs,
|
|
245
|
-
|
|
254
|
+
};
|
|
246
255
|
}
|
|
247
256
|
}
|
|
248
257
|
|
|
@@ -250,7 +259,7 @@ export class HFInferenceAudioToAudioTask extends HFInferenceTask implements Audi
|
|
|
250
259
|
override async getResponse(response: AudioToAudioOutput[]): Promise<AudioToAudioOutput[]> {
|
|
251
260
|
if (!Array.isArray(response)) {
|
|
252
261
|
throw new InferenceClientProviderOutputError(
|
|
253
|
-
"Received malformed response from HF-Inference audio-to-audio API: expected Array"
|
|
262
|
+
"Received malformed response from HF-Inference audio-to-audio API: expected Array",
|
|
254
263
|
);
|
|
255
264
|
}
|
|
256
265
|
if (
|
|
@@ -268,7 +277,7 @@ export class HFInferenceAudioToAudioTask extends HFInferenceTask implements Audi
|
|
|
268
277
|
})
|
|
269
278
|
) {
|
|
270
279
|
throw new InferenceClientProviderOutputError(
|
|
271
|
-
"Received malformed response from HF-Inference audio-to-audio API: expected Array<{label: string, audio: Blob}>"
|
|
280
|
+
"Received malformed response from HF-Inference audio-to-audio API: expected Array<{label: string, audio: Blob}>",
|
|
272
281
|
);
|
|
273
282
|
}
|
|
274
283
|
return response;
|
|
@@ -280,7 +289,7 @@ export class HFInferenceDocumentQuestionAnsweringTask
|
|
|
280
289
|
implements DocumentQuestionAnsweringTaskHelper
|
|
281
290
|
{
|
|
282
291
|
override async getResponse(
|
|
283
|
-
response: DocumentQuestionAnsweringOutput
|
|
292
|
+
response: DocumentQuestionAnsweringOutput,
|
|
284
293
|
): Promise<DocumentQuestionAnsweringOutput[number]> {
|
|
285
294
|
if (
|
|
286
295
|
Array.isArray(response) &&
|
|
@@ -291,13 +300,13 @@ export class HFInferenceDocumentQuestionAnsweringTask
|
|
|
291
300
|
typeof elem?.answer === "string" &&
|
|
292
301
|
(typeof elem.end === "number" || typeof elem.end === "undefined") &&
|
|
293
302
|
(typeof elem.score === "number" || typeof elem.score === "undefined") &&
|
|
294
|
-
(typeof elem.start === "number" || typeof elem.start === "undefined")
|
|
303
|
+
(typeof elem.start === "number" || typeof elem.start === "undefined"),
|
|
295
304
|
)
|
|
296
305
|
) {
|
|
297
306
|
return response[0];
|
|
298
307
|
}
|
|
299
308
|
throw new InferenceClientProviderOutputError(
|
|
300
|
-
"Received malformed response from HF-Inference document-question-answering API: expected Array<{answer: string, end: number, score: number, start: number}>"
|
|
309
|
+
"Received malformed response from HF-Inference document-question-answering API: expected Array<{answer: string, end: number, score: number, start: number}>",
|
|
301
310
|
);
|
|
302
311
|
}
|
|
303
312
|
}
|
|
@@ -316,7 +325,7 @@ export class HFInferenceFeatureExtractionTask extends HFInferenceTask implements
|
|
|
316
325
|
return response;
|
|
317
326
|
}
|
|
318
327
|
throw new InferenceClientProviderOutputError(
|
|
319
|
-
"Received malformed response from HF-Inference feature-extraction API: expected Array<number[][][] | number[][] | number[] | number>"
|
|
328
|
+
"Received malformed response from HF-Inference feature-extraction API: expected Array<number[][][] | number[][] | number[] | number>",
|
|
320
329
|
);
|
|
321
330
|
}
|
|
322
331
|
}
|
|
@@ -327,7 +336,7 @@ export class HFInferenceImageClassificationTask extends HFInferenceTask implemen
|
|
|
327
336
|
return response;
|
|
328
337
|
}
|
|
329
338
|
throw new InferenceClientProviderOutputError(
|
|
330
|
-
"Received malformed response from HF-Inference image-classification API: expected Array<{label: string, score: number}>"
|
|
339
|
+
"Received malformed response from HF-Inference image-classification API: expected Array<{label: string, score: number}>",
|
|
331
340
|
);
|
|
332
341
|
}
|
|
333
342
|
}
|
|
@@ -340,13 +349,13 @@ export class HFInferenceImageSegmentationTask extends HFInferenceTask implements
|
|
|
340
349
|
(x) =>
|
|
341
350
|
typeof x.label === "string" &&
|
|
342
351
|
typeof x.mask === "string" &&
|
|
343
|
-
(x.score === undefined || typeof x.score === "number")
|
|
352
|
+
(x.score === undefined || typeof x.score === "number"),
|
|
344
353
|
)
|
|
345
354
|
) {
|
|
346
355
|
return response;
|
|
347
356
|
}
|
|
348
357
|
throw new InferenceClientProviderOutputError(
|
|
349
|
-
"Received malformed response from HF-Inference image-segmentation API: expected Array<{label: string, mask: string, score: number}>"
|
|
358
|
+
"Received malformed response from HF-Inference image-segmentation API: expected Array<{label: string, mask: string, score: number}>",
|
|
350
359
|
);
|
|
351
360
|
}
|
|
352
361
|
|
|
@@ -354,7 +363,7 @@ export class HFInferenceImageSegmentationTask extends HFInferenceTask implements
|
|
|
354
363
|
return {
|
|
355
364
|
...args,
|
|
356
365
|
inputs: base64FromBytes(
|
|
357
|
-
new Uint8Array(args.inputs instanceof ArrayBuffer ? args.inputs : await (args.inputs as Blob).arrayBuffer())
|
|
366
|
+
new Uint8Array(args.inputs instanceof ArrayBuffer ? args.inputs : await (args.inputs as Blob).arrayBuffer()),
|
|
358
367
|
),
|
|
359
368
|
};
|
|
360
369
|
}
|
|
@@ -364,7 +373,7 @@ export class HFInferenceImageToTextTask extends HFInferenceTask implements Image
|
|
|
364
373
|
override async getResponse(response: ImageToTextOutput): Promise<ImageToTextOutput> {
|
|
365
374
|
if (typeof response?.generated_text !== "string") {
|
|
366
375
|
throw new InferenceClientProviderOutputError(
|
|
367
|
-
"Received malformed response from HF-Inference image-to-text API: expected {generated_text: string}"
|
|
376
|
+
"Received malformed response from HF-Inference image-to-text API: expected {generated_text: string}",
|
|
368
377
|
);
|
|
369
378
|
}
|
|
370
379
|
return response;
|
|
@@ -383,7 +392,7 @@ export class HFInferenceImageToImageTask extends HFInferenceTask implements Imag
|
|
|
383
392
|
return {
|
|
384
393
|
...args,
|
|
385
394
|
inputs: base64FromBytes(
|
|
386
|
-
new Uint8Array(args.inputs instanceof ArrayBuffer ? args.inputs : await (args.inputs as Blob).arrayBuffer())
|
|
395
|
+
new Uint8Array(args.inputs instanceof ArrayBuffer ? args.inputs : await (args.inputs as Blob).arrayBuffer()),
|
|
387
396
|
),
|
|
388
397
|
};
|
|
389
398
|
}
|
|
@@ -394,7 +403,7 @@ export class HFInferenceImageToImageTask extends HFInferenceTask implements Imag
|
|
|
394
403
|
return response;
|
|
395
404
|
}
|
|
396
405
|
throw new InferenceClientProviderOutputError(
|
|
397
|
-
"Received malformed response from HF-Inference image-to-image API: expected Blob"
|
|
406
|
+
"Received malformed response from HF-Inference image-to-image API: expected Blob",
|
|
398
407
|
);
|
|
399
408
|
}
|
|
400
409
|
}
|
|
@@ -410,13 +419,13 @@ export class HFInferenceObjectDetectionTask extends HFInferenceTask implements O
|
|
|
410
419
|
typeof x.box.xmin === "number" &&
|
|
411
420
|
typeof x.box.ymin === "number" &&
|
|
412
421
|
typeof x.box.xmax === "number" &&
|
|
413
|
-
typeof x.box.ymax === "number"
|
|
422
|
+
typeof x.box.ymax === "number",
|
|
414
423
|
)
|
|
415
424
|
) {
|
|
416
425
|
return response;
|
|
417
426
|
}
|
|
418
427
|
throw new InferenceClientProviderOutputError(
|
|
419
|
-
"Received malformed response from HF-Inference object-detection API: expected Array<{label: string, score: number, box: {xmin: number, ymin: number, xmax: number, ymax: number}}>"
|
|
428
|
+
"Received malformed response from HF-Inference object-detection API: expected Array<{label: string, score: number, box: {xmin: number, ymin: number, xmax: number, ymax: number}}>",
|
|
420
429
|
);
|
|
421
430
|
}
|
|
422
431
|
}
|
|
@@ -430,7 +439,7 @@ export class HFInferenceZeroShotImageClassificationTask
|
|
|
430
439
|
return response;
|
|
431
440
|
}
|
|
432
441
|
throw new InferenceClientProviderOutputError(
|
|
433
|
-
"Received malformed response from HF-Inference zero-shot-image-classification API: expected Array<{label: string, score: number}>"
|
|
442
|
+
"Received malformed response from HF-Inference zero-shot-image-classification API: expected Array<{label: string, score: number}>",
|
|
434
443
|
);
|
|
435
444
|
}
|
|
436
445
|
}
|
|
@@ -442,14 +451,14 @@ export class HFInferenceTextClassificationTask extends HFInferenceTask implement
|
|
|
442
451
|
return output;
|
|
443
452
|
}
|
|
444
453
|
throw new InferenceClientProviderOutputError(
|
|
445
|
-
"Received malformed response from HF-Inference text-classification API: expected Array<{label: string, score: number}>"
|
|
454
|
+
"Received malformed response from HF-Inference text-classification API: expected Array<{label: string, score: number}>",
|
|
446
455
|
);
|
|
447
456
|
}
|
|
448
457
|
}
|
|
449
458
|
|
|
450
459
|
export class HFInferenceQuestionAnsweringTask extends HFInferenceTask implements QuestionAnsweringTaskHelper {
|
|
451
460
|
override async getResponse(
|
|
452
|
-
response: QuestionAnsweringOutput | QuestionAnsweringOutput[number]
|
|
461
|
+
response: QuestionAnsweringOutput | QuestionAnsweringOutput[number],
|
|
453
462
|
): Promise<QuestionAnsweringOutputElement> {
|
|
454
463
|
if (
|
|
455
464
|
Array.isArray(response)
|
|
@@ -460,19 +469,19 @@ export class HFInferenceQuestionAnsweringTask extends HFInferenceTask implements
|
|
|
460
469
|
typeof elem.answer === "string" &&
|
|
461
470
|
typeof elem.end === "number" &&
|
|
462
471
|
typeof elem.score === "number" &&
|
|
463
|
-
typeof elem.start === "number"
|
|
464
|
-
|
|
472
|
+
typeof elem.start === "number",
|
|
473
|
+
)
|
|
465
474
|
: typeof response === "object" &&
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
475
|
+
!!response &&
|
|
476
|
+
typeof response.answer === "string" &&
|
|
477
|
+
typeof response.end === "number" &&
|
|
478
|
+
typeof response.score === "number" &&
|
|
479
|
+
typeof response.start === "number"
|
|
471
480
|
) {
|
|
472
481
|
return Array.isArray(response) ? response[0] : response;
|
|
473
482
|
}
|
|
474
483
|
throw new InferenceClientProviderOutputError(
|
|
475
|
-
"Received malformed response from HF-Inference question-answering API: expected Array<{answer: string, end: number, score: number, start: number}>"
|
|
484
|
+
"Received malformed response from HF-Inference question-answering API: expected Array<{answer: string, end: number, score: number, start: number}>",
|
|
476
485
|
);
|
|
477
486
|
}
|
|
478
487
|
}
|
|
@@ -486,13 +495,13 @@ export class HFInferenceFillMaskTask extends HFInferenceTask implements FillMask
|
|
|
486
495
|
typeof x.score === "number" &&
|
|
487
496
|
typeof x.sequence === "string" &&
|
|
488
497
|
typeof x.token === "number" &&
|
|
489
|
-
typeof x.token_str === "string"
|
|
498
|
+
typeof x.token_str === "string",
|
|
490
499
|
)
|
|
491
500
|
) {
|
|
492
501
|
return response;
|
|
493
502
|
}
|
|
494
503
|
throw new InferenceClientProviderOutputError(
|
|
495
|
-
"Received malformed response from HF-Inference fill-mask API: expected Array<{score: number, sequence: string, token: number, token_str: string}>"
|
|
504
|
+
"Received malformed response from HF-Inference fill-mask API: expected Array<{score: number, sequence: string, token: number, token_str: string}>",
|
|
496
505
|
);
|
|
497
506
|
}
|
|
498
507
|
}
|
|
@@ -522,7 +531,7 @@ export class HFInferenceZeroShotClassificationTask extends HFInferenceTask imple
|
|
|
522
531
|
return response;
|
|
523
532
|
}
|
|
524
533
|
throw new InferenceClientProviderOutputError(
|
|
525
|
-
"Received malformed response from HF-Inference zero-shot-classification API: expected Array<{label: string, score: number}>"
|
|
534
|
+
"Received malformed response from HF-Inference zero-shot-classification API: expected Array<{label: string, score: number}>",
|
|
526
535
|
);
|
|
527
536
|
}
|
|
528
537
|
|
|
@@ -544,7 +553,7 @@ export class HFInferenceSentenceSimilarityTask extends HFInferenceTask implement
|
|
|
544
553
|
return response;
|
|
545
554
|
}
|
|
546
555
|
throw new InferenceClientProviderOutputError(
|
|
547
|
-
"Received malformed response from HF-Inference sentence-similarity API: expected Array<number>"
|
|
556
|
+
"Received malformed response from HF-Inference sentence-similarity API: expected Array<number>",
|
|
548
557
|
);
|
|
549
558
|
}
|
|
550
559
|
}
|
|
@@ -564,7 +573,7 @@ export class HFInferenceTableQuestionAnsweringTask extends HFInferenceTask imple
|
|
|
564
573
|
"coordinates" in elem &&
|
|
565
574
|
Array.isArray(elem.coordinates) &&
|
|
566
575
|
elem.coordinates.every(
|
|
567
|
-
(coord: unknown): coord is number[] => Array.isArray(coord) && coord.every((x) => typeof x === "number")
|
|
576
|
+
(coord: unknown): coord is number[] => Array.isArray(coord) && coord.every((x) => typeof x === "number"),
|
|
568
577
|
)
|
|
569
578
|
);
|
|
570
579
|
}
|
|
@@ -577,7 +586,7 @@ export class HFInferenceTableQuestionAnsweringTask extends HFInferenceTask imple
|
|
|
577
586
|
return Array.isArray(response) ? response[0] : response;
|
|
578
587
|
}
|
|
579
588
|
throw new InferenceClientProviderOutputError(
|
|
580
|
-
"Received malformed response from HF-Inference table-question-answering API: expected {aggregator: string, answer: string, cells: string[], coordinates: number[][]}"
|
|
589
|
+
"Received malformed response from HF-Inference table-question-answering API: expected {aggregator: string, answer: string, cells: string[], coordinates: number[][]}",
|
|
581
590
|
);
|
|
582
591
|
}
|
|
583
592
|
}
|
|
@@ -592,13 +601,13 @@ export class HFInferenceTokenClassificationTask extends HFInferenceTask implemen
|
|
|
592
601
|
typeof x.entity_group === "string" &&
|
|
593
602
|
typeof x.score === "number" &&
|
|
594
603
|
typeof x.start === "number" &&
|
|
595
|
-
typeof x.word === "string"
|
|
604
|
+
typeof x.word === "string",
|
|
596
605
|
)
|
|
597
606
|
) {
|
|
598
607
|
return response;
|
|
599
608
|
}
|
|
600
609
|
throw new InferenceClientProviderOutputError(
|
|
601
|
-
"Received malformed response from HF-Inference token-classification API: expected Array<{end: number, entity_group: string, score: number, start: number, word: string}>"
|
|
610
|
+
"Received malformed response from HF-Inference token-classification API: expected Array<{end: number, entity_group: string, score: number, start: number, word: string}>",
|
|
602
611
|
);
|
|
603
612
|
}
|
|
604
613
|
}
|
|
@@ -609,7 +618,7 @@ export class HFInferenceTranslationTask extends HFInferenceTask implements Trans
|
|
|
609
618
|
return response?.length === 1 ? response?.[0] : response;
|
|
610
619
|
}
|
|
611
620
|
throw new InferenceClientProviderOutputError(
|
|
612
|
-
"Received malformed response from HF-Inference translation API: expected Array<{translation_text: string}>"
|
|
621
|
+
"Received malformed response from HF-Inference translation API: expected Array<{translation_text: string}>",
|
|
613
622
|
);
|
|
614
623
|
}
|
|
615
624
|
}
|
|
@@ -620,7 +629,7 @@ export class HFInferenceSummarizationTask extends HFInferenceTask implements Sum
|
|
|
620
629
|
return response?.[0];
|
|
621
630
|
}
|
|
622
631
|
throw new InferenceClientProviderOutputError(
|
|
623
|
-
"Received malformed response from HF-Inference summarization API: expected Array<{summary_text: string}>"
|
|
632
|
+
"Received malformed response from HF-Inference summarization API: expected Array<{summary_text: string}>",
|
|
624
633
|
);
|
|
625
634
|
}
|
|
626
635
|
}
|
|
@@ -637,7 +646,7 @@ export class HFInferenceTabularClassificationTask extends HFInferenceTask implem
|
|
|
637
646
|
return response;
|
|
638
647
|
}
|
|
639
648
|
throw new InferenceClientProviderOutputError(
|
|
640
|
-
"Received malformed response from HF-Inference tabular-classification API: expected Array<number>"
|
|
649
|
+
"Received malformed response from HF-Inference tabular-classification API: expected Array<number>",
|
|
641
650
|
);
|
|
642
651
|
}
|
|
643
652
|
}
|
|
@@ -651,13 +660,13 @@ export class HFInferenceVisualQuestionAnsweringTask
|
|
|
651
660
|
Array.isArray(response) &&
|
|
652
661
|
response.every(
|
|
653
662
|
(elem) =>
|
|
654
|
-
typeof elem === "object" && !!elem && typeof elem?.answer === "string" && typeof elem.score === "number"
|
|
663
|
+
typeof elem === "object" && !!elem && typeof elem?.answer === "string" && typeof elem.score === "number",
|
|
655
664
|
)
|
|
656
665
|
) {
|
|
657
666
|
return response[0];
|
|
658
667
|
}
|
|
659
668
|
throw new InferenceClientProviderOutputError(
|
|
660
|
-
"Received malformed response from HF-Inference visual-question-answering API: expected Array<{answer: string, score: number}>"
|
|
669
|
+
"Received malformed response from HF-Inference visual-question-answering API: expected Array<{answer: string, score: number}>",
|
|
661
670
|
);
|
|
662
671
|
}
|
|
663
672
|
}
|
|
@@ -668,7 +677,7 @@ export class HFInferenceTabularRegressionTask extends HFInferenceTask implements
|
|
|
668
677
|
return response;
|
|
669
678
|
}
|
|
670
679
|
throw new InferenceClientProviderOutputError(
|
|
671
|
-
"Received malformed response from HF-Inference tabular-regression API: expected Array<number>"
|
|
680
|
+
"Received malformed response from HF-Inference tabular-regression API: expected Array<number>",
|
|
672
681
|
);
|
|
673
682
|
}
|
|
674
683
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
import type { ChatCompletionOutput, TextGenerationOutput } from "@huggingface/tasks";
|
|
18
|
-
import type { BodyParams, UrlParams } from "../types.js";
|
|
18
|
+
import type { BodyParams, OutputType, UrlParams } from "../types.js";
|
|
19
19
|
import { omit } from "../utils/omit.js";
|
|
20
20
|
import {
|
|
21
21
|
BaseConversationalTask,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
TaskProviderHelper,
|
|
24
24
|
type TextToImageTaskHelper,
|
|
25
25
|
} from "./providerHelper.js";
|
|
26
|
-
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
26
|
+
import { InferenceClientInputError, InferenceClientProviderOutputError } from "../errors.js";
|
|
27
27
|
const HYPERBOLIC_API_BASE_URL = "https://api.hyperbolic.xyz";
|
|
28
28
|
|
|
29
29
|
export interface HyperbolicTextCompletionOutput extends Omit<ChatCompletionOutput, "choices"> {
|
|
@@ -58,7 +58,7 @@ export class HyperbolicTextGenerationTask extends BaseTextGenerationTask {
|
|
|
58
58
|
? {
|
|
59
59
|
max_tokens: (params.args.parameters as Record<string, unknown>).max_new_tokens,
|
|
60
60
|
...omit(params.args.parameters as Record<string, unknown>, "max_new_tokens"),
|
|
61
|
-
|
|
61
|
+
}
|
|
62
62
|
: undefined),
|
|
63
63
|
...omit(params.args, ["inputs", "parameters"]),
|
|
64
64
|
model: params.model,
|
|
@@ -93,6 +93,11 @@ export class HyperbolicTextToImageTask extends TaskProviderHelper implements Tex
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
preparePayload(params: BodyParams): Record<string, unknown> {
|
|
96
|
+
if (params.outputType === "url") {
|
|
97
|
+
throw new InferenceClientInputError(
|
|
98
|
+
"hyperbolic provider does not support URL output. Use outputType 'blob', 'dataUrl' or 'json' instead.",
|
|
99
|
+
);
|
|
100
|
+
}
|
|
96
101
|
return {
|
|
97
102
|
...omit(params.args, ["inputs", "parameters"]),
|
|
98
103
|
...(params.args.parameters as Record<string, unknown>),
|
|
@@ -105,7 +110,7 @@ export class HyperbolicTextToImageTask extends TaskProviderHelper implements Tex
|
|
|
105
110
|
response: HyperbolicTextToImageOutput,
|
|
106
111
|
url?: string,
|
|
107
112
|
headers?: HeadersInit,
|
|
108
|
-
outputType?:
|
|
113
|
+
outputType?: OutputType,
|
|
109
114
|
): Promise<string | Blob | Record<string, unknown>> {
|
|
110
115
|
if (
|
|
111
116
|
typeof response === "object" &&
|
|
@@ -117,7 +122,7 @@ export class HyperbolicTextToImageTask extends TaskProviderHelper implements Tex
|
|
|
117
122
|
if (outputType === "json") {
|
|
118
123
|
return { ...response };
|
|
119
124
|
}
|
|
120
|
-
if (outputType === "
|
|
125
|
+
if (outputType === "dataUrl") {
|
|
121
126
|
return `data:image/jpeg;base64,${response.images[0].image}`;
|
|
122
127
|
}
|
|
123
128
|
return fetch(`data:image/jpeg;base64,${response.images[0].image}`).then((res) => res.blob());
|
package/src/providers/nebius.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
import type { FeatureExtractionOutput, TextGenerationOutput } from "@huggingface/tasks";
|
|
18
|
-
import type { BodyParams } from "../types.js";
|
|
18
|
+
import type { BodyParams, OutputType } from "../types.js";
|
|
19
19
|
import { omit } from "../utils/omit.js";
|
|
20
20
|
import {
|
|
21
21
|
BaseConversationalTask,
|
|
@@ -29,9 +29,10 @@ import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js"
|
|
|
29
29
|
|
|
30
30
|
const NEBIUS_API_BASE_URL = "https://api.studio.nebius.ai";
|
|
31
31
|
|
|
32
|
-
interface
|
|
32
|
+
interface NebiusImageGeneration {
|
|
33
33
|
data: Array<{
|
|
34
|
-
b64_json
|
|
34
|
+
b64_json?: string;
|
|
35
|
+
url?: string;
|
|
35
36
|
}>;
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -102,7 +103,7 @@ export class NebiusTextToImageTask extends TaskProviderHelper implements TextToI
|
|
|
102
103
|
return {
|
|
103
104
|
...omit(params.args, ["inputs", "parameters"]),
|
|
104
105
|
...(params.args.parameters as Record<string, unknown>),
|
|
105
|
-
response_format: "b64_json",
|
|
106
|
+
response_format: params.outputType === "url" ? "url" : "b64_json",
|
|
106
107
|
prompt: params.args.inputs,
|
|
107
108
|
model: params.model,
|
|
108
109
|
};
|
|
@@ -113,27 +114,32 @@ export class NebiusTextToImageTask extends TaskProviderHelper implements TextToI
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
async getResponse(
|
|
116
|
-
response:
|
|
117
|
+
response: NebiusImageGeneration,
|
|
117
118
|
url?: string,
|
|
118
119
|
headers?: HeadersInit,
|
|
119
|
-
outputType?:
|
|
120
|
+
outputType?: OutputType,
|
|
120
121
|
): Promise<string | Blob | Record<string, unknown>> {
|
|
121
122
|
if (
|
|
122
123
|
typeof response === "object" &&
|
|
123
124
|
"data" in response &&
|
|
124
125
|
Array.isArray(response.data) &&
|
|
125
|
-
response.data.length > 0
|
|
126
|
-
"b64_json" in response.data[0] &&
|
|
127
|
-
typeof response.data[0].b64_json === "string"
|
|
126
|
+
response.data.length > 0
|
|
128
127
|
) {
|
|
129
128
|
if (outputType === "json") {
|
|
130
129
|
return { ...response };
|
|
131
130
|
}
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
return
|
|
131
|
+
|
|
132
|
+
if ("url" in response.data[0] && typeof response.data[0].url === "string") {
|
|
133
|
+
return response.data[0].url;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if ("b64_json" in response.data[0] && typeof response.data[0].b64_json === "string") {
|
|
137
|
+
const base64Data = response.data[0].b64_json;
|
|
138
|
+
if (outputType === "dataUrl") {
|
|
139
|
+
return `data:image/jpeg;base64,${base64Data}`;
|
|
140
|
+
}
|
|
141
|
+
return fetch(`data:image/jpeg;base64,${base64Data}`).then((res) => res.blob());
|
|
135
142
|
}
|
|
136
|
-
return fetch(`data:image/jpeg;base64,${base64Data}`).then((res) => res.blob());
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
throw new InferenceClientProviderOutputError("Received malformed response from Nebius text-to-image API");
|
package/src/providers/novita.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class NovitaTextToVideoTask extends TaskProviderHelper implements TextToV
|
|
|
79
79
|
override async getResponse(
|
|
80
80
|
response: NovitaAsyncAPIOutput,
|
|
81
81
|
url?: string,
|
|
82
|
-
headers?: Record<string, string
|
|
82
|
+
headers?: Record<string, string>,
|
|
83
83
|
): Promise<Blob> {
|
|
84
84
|
if (!url || !headers) {
|
|
85
85
|
throw new InferenceClientInputError("URL and headers are required for text-to-video task");
|
|
@@ -87,7 +87,7 @@ export class NovitaTextToVideoTask extends TaskProviderHelper implements TextToV
|
|
|
87
87
|
const taskId = response.task_id;
|
|
88
88
|
if (!taskId) {
|
|
89
89
|
throw new InferenceClientProviderOutputError(
|
|
90
|
-
"Received malformed response from Novita text-to-video API: no task ID found in the response"
|
|
90
|
+
"Received malformed response from Novita text-to-video API: no task ID found in the response",
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -111,7 +111,7 @@ export class NovitaTextToVideoTask extends TaskProviderHelper implements TextToV
|
|
|
111
111
|
requestId: resultResponse.headers.get("x-request-id") ?? "",
|
|
112
112
|
status: resultResponse.status,
|
|
113
113
|
body: await resultResponse.text(),
|
|
114
|
-
}
|
|
114
|
+
},
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
try {
|
|
@@ -128,12 +128,12 @@ export class NovitaTextToVideoTask extends TaskProviderHelper implements TextToV
|
|
|
128
128
|
status = taskResult.task.status;
|
|
129
129
|
} else {
|
|
130
130
|
throw new InferenceClientProviderOutputError(
|
|
131
|
-
"Received malformed response from Novita text-to-video API: failed to get task status"
|
|
131
|
+
"Received malformed response from Novita text-to-video API: failed to get task status",
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
134
|
} catch (error) {
|
|
135
135
|
throw new InferenceClientProviderOutputError(
|
|
136
|
-
"Received malformed response from Novita text-to-video API: failed to parse task result"
|
|
136
|
+
"Received malformed response from Novita text-to-video API: failed to parse task result",
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -159,8 +159,8 @@ export class NovitaTextToVideoTask extends TaskProviderHelper implements TextToV
|
|
|
159
159
|
} else {
|
|
160
160
|
throw new InferenceClientProviderOutputError(
|
|
161
161
|
`Received malformed response from Novita text-to-video API: expected { videos: [{ video_url: string }] } format, got instead: ${JSON.stringify(
|
|
162
|
-
taskResult
|
|
163
|
-
)}
|
|
162
|
+
taskResult,
|
|
163
|
+
)}`,
|
|
164
164
|
);
|
|
165
165
|
}
|
|
166
166
|
}
|
package/src/providers/nscale.ts
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
import type { TextToImageInput } from "@huggingface/tasks";
|
|
18
|
-
import type { BodyParams } from "../types.js";
|
|
18
|
+
import type { BodyParams, OutputType } from "../types.js";
|
|
19
19
|
import { omit } from "../utils/omit.js";
|
|
20
20
|
import { BaseConversationalTask, TaskProviderHelper, type TextToImageTaskHelper } from "./providerHelper.js";
|
|
21
|
-
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
21
|
+
import { InferenceClientInputError, InferenceClientProviderOutputError } from "../errors.js";
|
|
22
22
|
|
|
23
23
|
const NSCALE_API_BASE_URL = "https://inference.api.nscale.com";
|
|
24
24
|
|
|
@@ -40,6 +40,11 @@ export class NscaleTextToImageTask extends TaskProviderHelper implements TextToI
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
preparePayload(params: BodyParams<TextToImageInput>): Record<string, unknown> {
|
|
43
|
+
if (params.outputType === "url") {
|
|
44
|
+
throw new InferenceClientInputError(
|
|
45
|
+
"nscale provider does not support URL output. Use outputType 'blob', 'dataUrl' or 'json' instead.",
|
|
46
|
+
);
|
|
47
|
+
}
|
|
43
48
|
return {
|
|
44
49
|
...omit(params.args, ["inputs", "parameters"]),
|
|
45
50
|
...params.args.parameters,
|
|
@@ -57,7 +62,7 @@ export class NscaleTextToImageTask extends TaskProviderHelper implements TextToI
|
|
|
57
62
|
response: NscaleCloudBase64ImageGeneration,
|
|
58
63
|
url?: string,
|
|
59
64
|
headers?: HeadersInit,
|
|
60
|
-
outputType?:
|
|
65
|
+
outputType?: OutputType,
|
|
61
66
|
): Promise<string | Blob | Record<string, unknown>> {
|
|
62
67
|
if (
|
|
63
68
|
typeof response === "object" &&
|
|
@@ -71,7 +76,7 @@ export class NscaleTextToImageTask extends TaskProviderHelper implements TextToI
|
|
|
71
76
|
return { ...response };
|
|
72
77
|
}
|
|
73
78
|
const base64Data = response.data[0].b64_json;
|
|
74
|
-
if (outputType === "
|
|
79
|
+
if (outputType === "dataUrl") {
|
|
75
80
|
return `data:image/jpeg;base64,${base64Data}`;
|
|
76
81
|
}
|
|
77
82
|
return fetch(`data:image/jpeg;base64,${base64Data}`).then((res) => res.blob());
|
|
@@ -52,7 +52,7 @@ export class OvhCloudTextGenerationTask extends BaseTextGenerationTask {
|
|
|
52
52
|
? {
|
|
53
53
|
max_tokens: (params.args.parameters as Record<string, unknown>).max_new_tokens,
|
|
54
54
|
...omit(params.args.parameters as Record<string, unknown>, "max_new_tokens"),
|
|
55
|
-
|
|
55
|
+
}
|
|
56
56
|
: undefined),
|
|
57
57
|
prompt: params.args.inputs,
|
|
58
58
|
};
|