@huggingface/inference 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -6
- package/dist/index.cjs +193 -76
- package/dist/index.js +193 -76
- package/dist/src/lib/makeRequestOptions.d.ts.map +1 -1
- package/dist/src/providers/fal-ai.d.ts.map +1 -1
- package/dist/src/providers/replicate.d.ts.map +1 -1
- package/dist/src/providers/together.d.ts.map +1 -1
- package/dist/src/tasks/audio/audioClassification.d.ts +4 -18
- package/dist/src/tasks/audio/audioClassification.d.ts.map +1 -1
- package/dist/src/tasks/audio/audioToAudio.d.ts +10 -9
- package/dist/src/tasks/audio/audioToAudio.d.ts.map +1 -1
- package/dist/src/tasks/audio/automaticSpeechRecognition.d.ts +3 -12
- package/dist/src/tasks/audio/automaticSpeechRecognition.d.ts.map +1 -1
- package/dist/src/tasks/audio/textToSpeech.d.ts +4 -8
- package/dist/src/tasks/audio/textToSpeech.d.ts.map +1 -1
- package/dist/src/tasks/audio/utils.d.ts +11 -0
- package/dist/src/tasks/audio/utils.d.ts.map +1 -0
- package/dist/src/tasks/cv/imageClassification.d.ts +3 -17
- package/dist/src/tasks/cv/imageClassification.d.ts.map +1 -1
- package/dist/src/tasks/cv/imageSegmentation.d.ts +3 -21
- package/dist/src/tasks/cv/imageSegmentation.d.ts.map +1 -1
- package/dist/src/tasks/cv/imageToImage.d.ts +3 -49
- package/dist/src/tasks/cv/imageToImage.d.ts.map +1 -1
- package/dist/src/tasks/cv/imageToText.d.ts +3 -12
- package/dist/src/tasks/cv/imageToText.d.ts.map +1 -1
- package/dist/src/tasks/cv/objectDetection.d.ts +3 -26
- package/dist/src/tasks/cv/objectDetection.d.ts.map +1 -1
- package/dist/src/tasks/cv/textToImage.d.ts +3 -38
- package/dist/src/tasks/cv/textToImage.d.ts.map +1 -1
- package/dist/src/tasks/cv/textToVideo.d.ts +6 -0
- package/dist/src/tasks/cv/textToVideo.d.ts.map +1 -0
- package/dist/src/tasks/cv/utils.d.ts +11 -0
- package/dist/src/tasks/cv/utils.d.ts.map +1 -0
- package/dist/src/tasks/cv/zeroShotImageClassification.d.ts +7 -15
- package/dist/src/tasks/cv/zeroShotImageClassification.d.ts.map +1 -1
- package/dist/src/tasks/multimodal/documentQuestionAnswering.d.ts +5 -28
- package/dist/src/tasks/multimodal/documentQuestionAnswering.d.ts.map +1 -1
- package/dist/src/tasks/multimodal/visualQuestionAnswering.d.ts +5 -20
- package/dist/src/tasks/multimodal/visualQuestionAnswering.d.ts.map +1 -1
- package/dist/src/tasks/nlp/fillMask.d.ts +2 -21
- package/dist/src/tasks/nlp/fillMask.d.ts.map +1 -1
- package/dist/src/tasks/nlp/questionAnswering.d.ts +3 -25
- package/dist/src/tasks/nlp/questionAnswering.d.ts.map +1 -1
- package/dist/src/tasks/nlp/sentenceSimilarity.d.ts +2 -13
- package/dist/src/tasks/nlp/sentenceSimilarity.d.ts.map +1 -1
- package/dist/src/tasks/nlp/summarization.d.ts +2 -42
- package/dist/src/tasks/nlp/summarization.d.ts.map +1 -1
- package/dist/src/tasks/nlp/tableQuestionAnswering.d.ts +3 -31
- package/dist/src/tasks/nlp/tableQuestionAnswering.d.ts.map +1 -1
- package/dist/src/tasks/nlp/textClassification.d.ts +2 -16
- package/dist/src/tasks/nlp/textClassification.d.ts.map +1 -1
- package/dist/src/tasks/nlp/tokenClassification.d.ts +2 -45
- package/dist/src/tasks/nlp/tokenClassification.d.ts.map +1 -1
- package/dist/src/tasks/nlp/translation.d.ts +2 -13
- package/dist/src/tasks/nlp/translation.d.ts.map +1 -1
- package/dist/src/tasks/nlp/zeroShotClassification.d.ts +2 -22
- package/dist/src/tasks/nlp/zeroShotClassification.d.ts.map +1 -1
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/lib/makeRequestOptions.ts +7 -5
- package/src/providers/fal-ai.ts +12 -0
- package/src/providers/replicate.ts +6 -3
- package/src/providers/together.ts +2 -0
- package/src/tasks/audio/audioClassification.ts +7 -22
- package/src/tasks/audio/audioToAudio.ts +43 -23
- package/src/tasks/audio/automaticSpeechRecognition.ts +35 -23
- package/src/tasks/audio/textToSpeech.ts +23 -14
- package/src/tasks/audio/utils.ts +18 -0
- package/src/tasks/cv/imageClassification.ts +5 -20
- package/src/tasks/cv/imageSegmentation.ts +5 -24
- package/src/tasks/cv/imageToImage.ts +4 -52
- package/src/tasks/cv/imageToText.ts +6 -15
- package/src/tasks/cv/objectDetection.ts +5 -30
- package/src/tasks/cv/textToImage.ts +14 -50
- package/src/tasks/cv/textToVideo.ts +67 -0
- package/src/tasks/cv/utils.ts +13 -0
- package/src/tasks/cv/zeroShotImageClassification.ts +32 -31
- package/src/tasks/multimodal/documentQuestionAnswering.ts +25 -43
- package/src/tasks/multimodal/visualQuestionAnswering.ts +20 -36
- package/src/tasks/nlp/fillMask.ts +2 -22
- package/src/tasks/nlp/questionAnswering.ts +22 -36
- package/src/tasks/nlp/sentenceSimilarity.ts +12 -15
- package/src/tasks/nlp/summarization.ts +2 -43
- package/src/tasks/nlp/tableQuestionAnswering.ts +25 -41
- package/src/tasks/nlp/textClassification.ts +3 -18
- package/src/tasks/nlp/tokenClassification.ts +2 -47
- package/src/tasks/nlp/translation.ts +3 -17
- package/src/tasks/nlp/zeroShotClassification.ts +2 -24
- package/src/types.ts +7 -1
package/dist/index.js
CHANGED
|
@@ -49,10 +49,22 @@ var FAL_AI_API_BASE_URL = "https://fal.run";
|
|
|
49
49
|
var FAL_AI_SUPPORTED_MODEL_IDS = {
|
|
50
50
|
"text-to-image": {
|
|
51
51
|
"black-forest-labs/FLUX.1-schnell": "fal-ai/flux/schnell",
|
|
52
|
-
"black-forest-labs/FLUX.1-dev": "fal-ai/flux/dev"
|
|
52
|
+
"black-forest-labs/FLUX.1-dev": "fal-ai/flux/dev",
|
|
53
|
+
"playgroundai/playground-v2.5-1024px-aesthetic": "fal-ai/playground-v25",
|
|
54
|
+
"ByteDance/SDXL-Lightning": "fal-ai/lightning-models",
|
|
55
|
+
"PixArt-alpha/PixArt-Sigma-XL-2-1024-MS": "fal-ai/pixart-sigma",
|
|
56
|
+
"stabilityai/stable-diffusion-3-medium": "fal-ai/stable-diffusion-v3-medium",
|
|
57
|
+
"Warlord-K/Sana-1024": "fal-ai/sana",
|
|
58
|
+
"fal/AuraFlow-v0.2": "fal-ai/aura-flow",
|
|
59
|
+
"stabilityai/stable-diffusion-3.5-large": "fal-ai/stable-diffusion-v35-large",
|
|
60
|
+
"Kwai-Kolors/Kolors": "fal-ai/kolors"
|
|
53
61
|
},
|
|
54
62
|
"automatic-speech-recognition": {
|
|
55
63
|
"openai/whisper-large-v3": "fal-ai/whisper"
|
|
64
|
+
},
|
|
65
|
+
"text-to-video": {
|
|
66
|
+
"genmo/mochi-1-preview": "fal-ai/mochi-v1",
|
|
67
|
+
"tencent/HunyuanVideo": "fal-ai/hunyuan-video"
|
|
56
68
|
}
|
|
57
69
|
};
|
|
58
70
|
|
|
@@ -62,10 +74,13 @@ var REPLICATE_SUPPORTED_MODEL_IDS = {
|
|
|
62
74
|
"text-to-image": {
|
|
63
75
|
"black-forest-labs/FLUX.1-schnell": "black-forest-labs/flux-schnell",
|
|
64
76
|
"ByteDance/SDXL-Lightning": "bytedance/sdxl-lightning-4step:5599ed30703defd1d160a25a63321b4dec97101d98b4674bcc56e41f62f35637"
|
|
77
|
+
},
|
|
78
|
+
"text-to-speech": {
|
|
79
|
+
"OuteAI/OuteTTS-0.3-500M": "jbilcke/oute-tts:39a59319327b27327fa3095149c5a746e7f2aee18c75055c3368237a6503cd26"
|
|
80
|
+
},
|
|
81
|
+
"text-to-video": {
|
|
82
|
+
"genmo/mochi-1-preview": "genmoai/mochi-1:1944af04d098ef69bed7f9d335d102e652203f268ec4aaa2d836f6217217e460"
|
|
65
83
|
}
|
|
66
|
-
// "text-to-speech": {
|
|
67
|
-
// "SWivid/F5-TTS": "x-lance/f5-tts:87faf6dd7a692dd82043f662e76369cab126a2cf1937e25a9d41e0b834fd230e"
|
|
68
|
-
// },
|
|
69
84
|
};
|
|
70
85
|
|
|
71
86
|
// src/providers/sambanova.ts
|
|
@@ -101,6 +116,8 @@ var TOGETHER_SUPPORTED_MODEL_IDS = {
|
|
|
101
116
|
},
|
|
102
117
|
conversational: {
|
|
103
118
|
"databricks/dbrx-instruct": "databricks/dbrx-instruct",
|
|
119
|
+
"deepseek-ai/DeepSeek-R1": "deepseek-ai/DeepSeek-R1",
|
|
120
|
+
"deepseek-ai/DeepSeek-V3": "deepseek-ai/DeepSeek-V3",
|
|
104
121
|
"deepseek-ai/deepseek-llm-67b-chat": "deepseek-ai/deepseek-llm-67b-chat",
|
|
105
122
|
"google/gemma-2-9b-it": "google/gemma-2-9b-it",
|
|
106
123
|
"google/gemma-2b-it": "google/gemma-2-27b-it",
|
|
@@ -146,7 +163,8 @@ function isUrl(modelOrUrl) {
|
|
|
146
163
|
var HF_HUB_INFERENCE_PROXY_TEMPLATE = `${HF_HUB_URL}/api/inference-proxy/{{PROVIDER}}`;
|
|
147
164
|
var tasks = null;
|
|
148
165
|
async function makeRequestOptions(args, options) {
|
|
149
|
-
const { accessToken, endpointUrl, provider: maybeProvider, model: maybeModel, ...
|
|
166
|
+
const { accessToken, endpointUrl, provider: maybeProvider, model: maybeModel, ...remainingArgs } = args;
|
|
167
|
+
let otherArgs = remainingArgs;
|
|
150
168
|
const provider = maybeProvider ?? "hf-inference";
|
|
151
169
|
const { forceTask, includeCredentials, taskHint, wait_for_model, use_cache, dont_load_model, chatCompletion: chatCompletion2 } = options ?? {};
|
|
152
170
|
if (endpointUrl && provider !== "hf-inference") {
|
|
@@ -205,9 +223,9 @@ async function makeRequestOptions(args, options) {
|
|
|
205
223
|
} else if (includeCredentials === true) {
|
|
206
224
|
credentials = "include";
|
|
207
225
|
}
|
|
208
|
-
if (provider === "replicate"
|
|
209
|
-
const version = model.split(":")[1];
|
|
210
|
-
otherArgs
|
|
226
|
+
if (provider === "replicate") {
|
|
227
|
+
const version = model.includes(":") ? model.split(":")[1] : void 0;
|
|
228
|
+
otherArgs = { input: otherArgs, version };
|
|
211
229
|
}
|
|
212
230
|
const info = {
|
|
213
231
|
headers,
|
|
@@ -527,9 +545,42 @@ var InferenceOutputError = class extends TypeError {
|
|
|
527
545
|
}
|
|
528
546
|
};
|
|
529
547
|
|
|
548
|
+
// src/utils/pick.ts
|
|
549
|
+
function pick(o, props) {
|
|
550
|
+
return Object.assign(
|
|
551
|
+
{},
|
|
552
|
+
...props.map((prop) => {
|
|
553
|
+
if (o[prop] !== void 0) {
|
|
554
|
+
return { [prop]: o[prop] };
|
|
555
|
+
}
|
|
556
|
+
})
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// src/utils/typedInclude.ts
|
|
561
|
+
function typedInclude(arr, v) {
|
|
562
|
+
return arr.includes(v);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// src/utils/omit.ts
|
|
566
|
+
function omit(o, props) {
|
|
567
|
+
const propsArr = Array.isArray(props) ? props : [props];
|
|
568
|
+
const letsKeep = Object.keys(o).filter((prop) => !typedInclude(propsArr, prop));
|
|
569
|
+
return pick(o, letsKeep);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/tasks/audio/utils.ts
|
|
573
|
+
function preparePayload(args) {
|
|
574
|
+
return "data" in args ? args : {
|
|
575
|
+
...omit(args, "inputs"),
|
|
576
|
+
data: args.inputs
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
|
|
530
580
|
// src/tasks/audio/audioClassification.ts
|
|
531
581
|
async function audioClassification(args, options) {
|
|
532
|
-
const
|
|
582
|
+
const payload = preparePayload(args);
|
|
583
|
+
const res = await request(payload, {
|
|
533
584
|
...options,
|
|
534
585
|
taskHint: "audio-classification"
|
|
535
586
|
});
|
|
@@ -555,15 +606,8 @@ function base64FromBytes(arr) {
|
|
|
555
606
|
|
|
556
607
|
// src/tasks/audio/automaticSpeechRecognition.ts
|
|
557
608
|
async function automaticSpeechRecognition(args, options) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const base64audio = base64FromBytes(
|
|
561
|
-
new Uint8Array(args.data instanceof ArrayBuffer ? args.data : await args.data.arrayBuffer())
|
|
562
|
-
);
|
|
563
|
-
args.audio_url = `data:${contentType};base64,${base64audio}`;
|
|
564
|
-
delete args.data;
|
|
565
|
-
}
|
|
566
|
-
const res = await request(args, {
|
|
609
|
+
const payload = await buildPayload(args);
|
|
610
|
+
const res = await request(payload, {
|
|
567
611
|
...options,
|
|
568
612
|
taskHint: "automatic-speech-recognition"
|
|
569
613
|
});
|
|
@@ -573,6 +617,32 @@ async function automaticSpeechRecognition(args, options) {
|
|
|
573
617
|
}
|
|
574
618
|
return res;
|
|
575
619
|
}
|
|
620
|
+
var FAL_AI_SUPPORTED_BLOB_TYPES = ["audio/mpeg", "audio/mp4", "audio/wav", "audio/x-wav"];
|
|
621
|
+
async function buildPayload(args) {
|
|
622
|
+
if (args.provider === "fal-ai") {
|
|
623
|
+
const blob = "data" in args && args.data instanceof Blob ? args.data : "inputs" in args ? args.inputs : void 0;
|
|
624
|
+
const contentType = blob?.type;
|
|
625
|
+
if (!contentType) {
|
|
626
|
+
throw new Error(
|
|
627
|
+
`Unable to determine the input's content-type. Make sure your are passing a Blob when using provider fal-ai.`
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
if (!FAL_AI_SUPPORTED_BLOB_TYPES.includes(contentType)) {
|
|
631
|
+
throw new Error(
|
|
632
|
+
`Provider fal-ai does not support blob type ${contentType} - supported content types are: ${FAL_AI_SUPPORTED_BLOB_TYPES.join(
|
|
633
|
+
", "
|
|
634
|
+
)}`
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
const base64audio = base64FromBytes(new Uint8Array(await blob.arrayBuffer()));
|
|
638
|
+
return {
|
|
639
|
+
..."data" in args ? omit(args, "data") : omit(args, "inputs"),
|
|
640
|
+
audio_url: `data:${contentType};base64,${base64audio}`
|
|
641
|
+
};
|
|
642
|
+
} else {
|
|
643
|
+
return preparePayload(args);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
576
646
|
|
|
577
647
|
// src/tasks/audio/textToSpeech.ts
|
|
578
648
|
async function textToSpeech(args, options) {
|
|
@@ -580,31 +650,55 @@ async function textToSpeech(args, options) {
|
|
|
580
650
|
...options,
|
|
581
651
|
taskHint: "text-to-speech"
|
|
582
652
|
});
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
throw new InferenceOutputError("Expected Blob");
|
|
653
|
+
if (res instanceof Blob) {
|
|
654
|
+
return res;
|
|
586
655
|
}
|
|
587
|
-
|
|
656
|
+
if (res && typeof res === "object") {
|
|
657
|
+
if ("output" in res) {
|
|
658
|
+
if (typeof res.output === "string") {
|
|
659
|
+
const urlResponse = await fetch(res.output);
|
|
660
|
+
const blob = await urlResponse.blob();
|
|
661
|
+
return blob;
|
|
662
|
+
} else if (Array.isArray(res.output)) {
|
|
663
|
+
const urlResponse = await fetch(res.output[0]);
|
|
664
|
+
const blob = await urlResponse.blob();
|
|
665
|
+
return blob;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
throw new InferenceOutputError("Expected Blob or object with output");
|
|
588
670
|
}
|
|
589
671
|
|
|
590
672
|
// src/tasks/audio/audioToAudio.ts
|
|
591
673
|
async function audioToAudio(args, options) {
|
|
592
|
-
const
|
|
674
|
+
const payload = preparePayload(args);
|
|
675
|
+
const res = await request(payload, {
|
|
593
676
|
...options,
|
|
594
677
|
taskHint: "audio-to-audio"
|
|
595
678
|
});
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
if (!
|
|
600
|
-
throw new InferenceOutputError("Expected Array
|
|
679
|
+
return validateOutput(res);
|
|
680
|
+
}
|
|
681
|
+
function validateOutput(output) {
|
|
682
|
+
if (!Array.isArray(output)) {
|
|
683
|
+
throw new InferenceOutputError("Expected Array");
|
|
601
684
|
}
|
|
602
|
-
|
|
685
|
+
if (!output.every((elem) => {
|
|
686
|
+
return typeof elem === "object" && elem && "label" in elem && typeof elem.label === "string" && "content-type" in elem && typeof elem["content-type"] === "string" && "blob" in elem && typeof elem.blob === "string";
|
|
687
|
+
})) {
|
|
688
|
+
throw new InferenceOutputError("Expected Array<{label: string, audio: Blob}>");
|
|
689
|
+
}
|
|
690
|
+
return output;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// src/tasks/cv/utils.ts
|
|
694
|
+
function preparePayload2(args) {
|
|
695
|
+
return "data" in args ? args : { ...omit(args, "inputs"), data: args.inputs };
|
|
603
696
|
}
|
|
604
697
|
|
|
605
698
|
// src/tasks/cv/imageClassification.ts
|
|
606
699
|
async function imageClassification(args, options) {
|
|
607
|
-
const
|
|
700
|
+
const payload = preparePayload2(args);
|
|
701
|
+
const res = await request(payload, {
|
|
608
702
|
...options,
|
|
609
703
|
taskHint: "image-classification"
|
|
610
704
|
});
|
|
@@ -617,7 +711,8 @@ async function imageClassification(args, options) {
|
|
|
617
711
|
|
|
618
712
|
// src/tasks/cv/imageSegmentation.ts
|
|
619
713
|
async function imageSegmentation(args, options) {
|
|
620
|
-
const
|
|
714
|
+
const payload = preparePayload2(args);
|
|
715
|
+
const res = await request(payload, {
|
|
621
716
|
...options,
|
|
622
717
|
taskHint: "image-segmentation"
|
|
623
718
|
});
|
|
@@ -630,7 +725,8 @@ async function imageSegmentation(args, options) {
|
|
|
630
725
|
|
|
631
726
|
// src/tasks/cv/imageToText.ts
|
|
632
727
|
async function imageToText(args, options) {
|
|
633
|
-
const
|
|
728
|
+
const payload = preparePayload2(args);
|
|
729
|
+
const res = (await request(payload, {
|
|
634
730
|
...options,
|
|
635
731
|
taskHint: "image-to-text"
|
|
636
732
|
}))?.[0];
|
|
@@ -642,7 +738,8 @@ async function imageToText(args, options) {
|
|
|
642
738
|
|
|
643
739
|
// src/tasks/cv/objectDetection.ts
|
|
644
740
|
async function objectDetection(args, options) {
|
|
645
|
-
const
|
|
741
|
+
const payload = preparePayload2(args);
|
|
742
|
+
const res = await request(payload, {
|
|
646
743
|
...options,
|
|
647
744
|
taskHint: "object-detection"
|
|
648
745
|
});
|
|
@@ -659,15 +756,13 @@ async function objectDetection(args, options) {
|
|
|
659
756
|
|
|
660
757
|
// src/tasks/cv/textToImage.ts
|
|
661
758
|
async function textToImage(args, options) {
|
|
662
|
-
|
|
663
|
-
args
|
|
664
|
-
args.
|
|
665
|
-
args.
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
const res = await request(args, {
|
|
759
|
+
const payload = args.provider === "together" || args.provider === "fal-ai" || args.provider === "replicate" ? {
|
|
760
|
+
...omit(args, ["inputs", "parameters"]),
|
|
761
|
+
...args.parameters,
|
|
762
|
+
...args.provider !== "replicate" ? { response_format: "base64" } : void 0,
|
|
763
|
+
prompt: args.inputs
|
|
764
|
+
} : args;
|
|
765
|
+
const res = await request(payload, {
|
|
671
766
|
...options,
|
|
672
767
|
taskHint: "text-to-image"
|
|
673
768
|
});
|
|
@@ -724,18 +819,30 @@ async function imageToImage(args, options) {
|
|
|
724
819
|
}
|
|
725
820
|
|
|
726
821
|
// src/tasks/cv/zeroShotImageClassification.ts
|
|
727
|
-
async function
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
new Uint8Array(
|
|
733
|
-
|
|
822
|
+
async function preparePayload3(args) {
|
|
823
|
+
if (args.inputs instanceof Blob) {
|
|
824
|
+
return {
|
|
825
|
+
...args,
|
|
826
|
+
inputs: {
|
|
827
|
+
image: base64FromBytes(new Uint8Array(await args.inputs.arrayBuffer()))
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
} else {
|
|
831
|
+
return {
|
|
832
|
+
...args,
|
|
833
|
+
inputs: {
|
|
834
|
+
image: base64FromBytes(
|
|
835
|
+
new Uint8Array(
|
|
836
|
+
args.inputs.image instanceof ArrayBuffer ? args.inputs.image : await args.inputs.image.arrayBuffer()
|
|
837
|
+
)
|
|
734
838
|
)
|
|
735
|
-
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
async function zeroShotImageClassification(args, options) {
|
|
844
|
+
const payload = await preparePayload3(args);
|
|
845
|
+
const res = await request(payload, {
|
|
739
846
|
...options,
|
|
740
847
|
taskHint: "zero-shot-image-classification"
|
|
741
848
|
});
|
|
@@ -824,17 +931,19 @@ async function questionAnswering(args, options) {
|
|
|
824
931
|
...options,
|
|
825
932
|
taskHint: "question-answering"
|
|
826
933
|
});
|
|
827
|
-
const isValidOutput =
|
|
934
|
+
const isValidOutput = Array.isArray(res) ? res.every(
|
|
935
|
+
(elem) => typeof elem === "object" && !!elem && typeof elem.answer === "string" && typeof elem.end === "number" && typeof elem.score === "number" && typeof elem.start === "number"
|
|
936
|
+
) : typeof res === "object" && !!res && typeof res.answer === "string" && typeof res.end === "number" && typeof res.score === "number" && typeof res.start === "number";
|
|
828
937
|
if (!isValidOutput) {
|
|
829
|
-
throw new InferenceOutputError("Expected {answer: string, end: number, score: number, start: number}");
|
|
938
|
+
throw new InferenceOutputError("Expected Array<{answer: string, end: number, score: number, start: number}>");
|
|
830
939
|
}
|
|
831
|
-
return res;
|
|
940
|
+
return Array.isArray(res) ? res[0] : res;
|
|
832
941
|
}
|
|
833
942
|
|
|
834
943
|
// src/tasks/nlp/sentenceSimilarity.ts
|
|
835
944
|
async function sentenceSimilarity(args, options) {
|
|
836
945
|
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken, options) : void 0;
|
|
837
|
-
const res = await request(args, {
|
|
946
|
+
const res = await request(prepareInput(args), {
|
|
838
947
|
...options,
|
|
839
948
|
taskHint: "sentence-similarity",
|
|
840
949
|
...defaultTask === "feature-extraction" && { forceTask: "sentence-similarity" }
|
|
@@ -845,6 +954,13 @@ async function sentenceSimilarity(args, options) {
|
|
|
845
954
|
}
|
|
846
955
|
return res;
|
|
847
956
|
}
|
|
957
|
+
function prepareInput(args) {
|
|
958
|
+
return {
|
|
959
|
+
...omit(args, ["inputs", "parameters"]),
|
|
960
|
+
inputs: { ...omit(args.inputs, "sourceSentence") },
|
|
961
|
+
parameters: { source_sentence: args.inputs.sourceSentence, ...args.parameters }
|
|
962
|
+
};
|
|
963
|
+
}
|
|
848
964
|
|
|
849
965
|
// src/tasks/nlp/summarization.ts
|
|
850
966
|
async function summarization(args, options) {
|
|
@@ -865,13 +981,18 @@ async function tableQuestionAnswering(args, options) {
|
|
|
865
981
|
...options,
|
|
866
982
|
taskHint: "table-question-answering"
|
|
867
983
|
});
|
|
868
|
-
const isValidOutput =
|
|
984
|
+
const isValidOutput = Array.isArray(res) ? res.every((elem) => validate(elem)) : validate(res);
|
|
869
985
|
if (!isValidOutput) {
|
|
870
986
|
throw new InferenceOutputError(
|
|
871
987
|
"Expected {aggregator: string, answer: string, cells: string[], coordinates: number[][]}"
|
|
872
988
|
);
|
|
873
989
|
}
|
|
874
|
-
return res;
|
|
990
|
+
return Array.isArray(res) ? res[0] : res;
|
|
991
|
+
}
|
|
992
|
+
function validate(elem) {
|
|
993
|
+
return typeof elem === "object" && !!elem && "aggregator" in elem && typeof elem.aggregator === "string" && "answer" in elem && typeof elem.answer === "string" && "cells" in elem && Array.isArray(elem.cells) && elem.cells.every((x) => typeof x === "string") && "coordinates" in elem && Array.isArray(elem.coordinates) && elem.coordinates.every(
|
|
994
|
+
(coord) => Array.isArray(coord) && coord.every((x) => typeof x === "number")
|
|
995
|
+
);
|
|
875
996
|
}
|
|
876
997
|
|
|
877
998
|
// src/tasks/nlp/textClassification.ts
|
|
@@ -1014,11 +1135,7 @@ async function documentQuestionAnswering(args, options) {
|
|
|
1014
1135
|
inputs: {
|
|
1015
1136
|
question: args.inputs.question,
|
|
1016
1137
|
// convert Blob or ArrayBuffer to base64
|
|
1017
|
-
image: base64FromBytes(
|
|
1018
|
-
new Uint8Array(
|
|
1019
|
-
args.inputs.image instanceof ArrayBuffer ? args.inputs.image : await args.inputs.image.arrayBuffer()
|
|
1020
|
-
)
|
|
1021
|
-
)
|
|
1138
|
+
image: base64FromBytes(new Uint8Array(await args.inputs.image.arrayBuffer()))
|
|
1022
1139
|
}
|
|
1023
1140
|
};
|
|
1024
1141
|
const res = toArray(
|
|
@@ -1026,12 +1143,14 @@ async function documentQuestionAnswering(args, options) {
|
|
|
1026
1143
|
...options,
|
|
1027
1144
|
taskHint: "document-question-answering"
|
|
1028
1145
|
})
|
|
1029
|
-
)
|
|
1030
|
-
const isValidOutput =
|
|
1146
|
+
);
|
|
1147
|
+
const isValidOutput = Array.isArray(res) && res.every(
|
|
1148
|
+
(elem) => typeof elem === "object" && !!elem && typeof elem?.answer === "string" && (typeof elem.end === "number" || typeof elem.end === "undefined") && (typeof elem.score === "number" || typeof elem.score === "undefined") && (typeof elem.start === "number" || typeof elem.start === "undefined")
|
|
1149
|
+
);
|
|
1031
1150
|
if (!isValidOutput) {
|
|
1032
1151
|
throw new InferenceOutputError("Expected Array<{answer: string, end?: number, score?: number, start?: number}>");
|
|
1033
1152
|
}
|
|
1034
|
-
return res;
|
|
1153
|
+
return res[0];
|
|
1035
1154
|
}
|
|
1036
1155
|
|
|
1037
1156
|
// src/tasks/multimodal/visualQuestionAnswering.ts
|
|
@@ -1041,22 +1160,20 @@ async function visualQuestionAnswering(args, options) {
|
|
|
1041
1160
|
inputs: {
|
|
1042
1161
|
question: args.inputs.question,
|
|
1043
1162
|
// convert Blob or ArrayBuffer to base64
|
|
1044
|
-
image: base64FromBytes(
|
|
1045
|
-
new Uint8Array(
|
|
1046
|
-
args.inputs.image instanceof ArrayBuffer ? args.inputs.image : await args.inputs.image.arrayBuffer()
|
|
1047
|
-
)
|
|
1048
|
-
)
|
|
1163
|
+
image: base64FromBytes(new Uint8Array(await args.inputs.image.arrayBuffer()))
|
|
1049
1164
|
}
|
|
1050
1165
|
};
|
|
1051
|
-
const res =
|
|
1166
|
+
const res = await request(reqArgs, {
|
|
1052
1167
|
...options,
|
|
1053
1168
|
taskHint: "visual-question-answering"
|
|
1054
|
-
})
|
|
1055
|
-
const isValidOutput =
|
|
1169
|
+
});
|
|
1170
|
+
const isValidOutput = Array.isArray(res) && res.every(
|
|
1171
|
+
(elem) => typeof elem === "object" && !!elem && typeof elem?.answer === "string" && typeof elem.score === "number"
|
|
1172
|
+
);
|
|
1056
1173
|
if (!isValidOutput) {
|
|
1057
1174
|
throw new InferenceOutputError("Expected Array<{answer: string, score: number}>");
|
|
1058
1175
|
}
|
|
1059
|
-
return res;
|
|
1176
|
+
return res[0];
|
|
1060
1177
|
}
|
|
1061
1178
|
|
|
1062
1179
|
// src/tasks/tabular/tabularRegression.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeRequestOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/makeRequestOptions.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAWpE;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,WAAW,GAAG;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EACD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IACnC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"makeRequestOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/makeRequestOptions.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAWpE;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,WAAW,GAAG;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EACD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IACnC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,CAiH7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fal-ai.d.ts","sourceRoot":"","sources":["../../../src/providers/fal-ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,KAAK,OAAO,GAAG,MAAM,CAAC;AAEtB,eAAO,MAAM,0BAA0B,EAAE,eAAe,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"fal-ai.d.ts","sourceRoot":"","sources":["../../../src/providers/fal-ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,KAAK,OAAO,GAAG,MAAM,CAAC;AAEtB,eAAO,MAAM,0BAA0B,EAAE,eAAe,CAAC,OAAO,CAoB/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replicate.d.ts","sourceRoot":"","sources":["../../../src/providers/replicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,sBAAsB,8BAA8B,CAAC;AAElE,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,eAAO,MAAM,6BAA6B,EAAE,eAAe,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"replicate.d.ts","sourceRoot":"","sources":["../../../src/providers/replicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,sBAAsB,8BAA8B,CAAC;AAElE,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,eAAO,MAAM,6BAA6B,EAAE,eAAe,CAAC,WAAW,CAYtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"together.d.ts","sourceRoot":"","sources":["../../../src/providers/together.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAEhE;;GAEG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,eAAe,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"together.d.ts","sourceRoot":"","sources":["../../../src/providers/together.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAEhE;;GAEG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,eAAe,CAAC,UAAU,CA+CpE,CAAC"}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
+
import type { AudioClassificationInput, AudioClassificationOutput } from "@huggingface/tasks";
|
|
1
2
|
import type { BaseArgs, Options } from "../../types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Binary audio data
|
|
5
|
-
*/
|
|
6
|
-
data: Blob | ArrayBuffer;
|
|
7
|
-
};
|
|
8
|
-
export interface AudioClassificationOutputValue {
|
|
9
|
-
/**
|
|
10
|
-
* The label for the class (model specific)
|
|
11
|
-
*/
|
|
12
|
-
label: string;
|
|
13
|
-
/**
|
|
14
|
-
* A float that represents how likely it is that the audio file belongs to this class.
|
|
15
|
-
*/
|
|
16
|
-
score: number;
|
|
17
|
-
}
|
|
18
|
-
export type AudioClassificationReturn = AudioClassificationOutputValue[];
|
|
3
|
+
import type { LegacyAudioInput } from "./utils";
|
|
4
|
+
export type AudioClassificationArgs = BaseArgs & (AudioClassificationInput | LegacyAudioInput);
|
|
19
5
|
/**
|
|
20
6
|
* This task reads some audio input and outputs the likelihood of classes.
|
|
21
7
|
* Recommended model: superb/hubert-large-superb-er
|
|
22
8
|
*/
|
|
23
|
-
export declare function audioClassification(args: AudioClassificationArgs, options?: Options): Promise<
|
|
9
|
+
export declare function audioClassification(args: AudioClassificationArgs, options?: Options): Promise<AudioClassificationOutput>;
|
|
24
10
|
//# sourceMappingURL=audioClassification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioClassification.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/audioClassification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audioClassification.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/audioClassification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE9F,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,CAAC,wBAAwB,GAAG,gBAAgB,CAAC,CAAC;AAE/F;;;GAGG;AACH,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,uBAAuB,EAC7B,OAAO,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,yBAAyB,CAAC,CAYpC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { BaseArgs, Options } from "../../types";
|
|
2
|
-
|
|
2
|
+
import type { LegacyAudioInput } from "./utils";
|
|
3
|
+
export type AudioToAudioArgs = (BaseArgs & {
|
|
3
4
|
/**
|
|
4
5
|
* Binary audio data
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export interface
|
|
7
|
+
inputs: Blob;
|
|
8
|
+
}) | LegacyAudioInput;
|
|
9
|
+
export interface AudioToAudioOutputElem {
|
|
9
10
|
/**
|
|
10
11
|
* The label for the audio output (model specific)
|
|
11
12
|
*/
|
|
@@ -13,16 +14,16 @@ export interface AudioToAudioOutputValue {
|
|
|
13
14
|
/**
|
|
14
15
|
* Base64 encoded audio output.
|
|
15
16
|
*/
|
|
17
|
+
audio: Blob;
|
|
18
|
+
}
|
|
19
|
+
export interface AudioToAudioOutput {
|
|
16
20
|
blob: string;
|
|
17
|
-
/**
|
|
18
|
-
* Content-type for blob, e.g. audio/flac
|
|
19
|
-
*/
|
|
20
21
|
"content-type": string;
|
|
22
|
+
label: string;
|
|
21
23
|
}
|
|
22
|
-
export type AudioToAudioReturn = AudioToAudioOutputValue[];
|
|
23
24
|
/**
|
|
24
25
|
* This task reads some audio input and outputs one or multiple audio files.
|
|
25
26
|
* Example model: speechbrain/sepformer-wham does audio source separation.
|
|
26
27
|
*/
|
|
27
|
-
export declare function audioToAudio(args: AudioToAudioArgs, options?: Options): Promise<
|
|
28
|
+
export declare function audioToAudio(args: AudioToAudioArgs, options?: Options): Promise<AudioToAudioOutput[]>;
|
|
28
29
|
//# sourceMappingURL=audioToAudio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioToAudio.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/audioToAudio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"audioToAudio.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/audioToAudio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,MAAM,MAAM,gBAAgB,GACzB,CAAC,QAAQ,GAAG;IACZ;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC;CACZ,CAAC,GACF,gBAAgB,CAAC;AAEpB,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAQ3G"}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
+
import type { AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput } from "@huggingface/tasks";
|
|
1
2
|
import type { BaseArgs, Options } from "../../types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Binary audio data
|
|
5
|
-
*/
|
|
6
|
-
data: Blob | ArrayBuffer;
|
|
7
|
-
};
|
|
8
|
-
export interface AutomaticSpeechRecognitionOutput {
|
|
9
|
-
/**
|
|
10
|
-
* The text that was recognized from the audio
|
|
11
|
-
*/
|
|
12
|
-
text: string;
|
|
13
|
-
}
|
|
3
|
+
import type { LegacyAudioInput } from "./utils";
|
|
4
|
+
export type AutomaticSpeechRecognitionArgs = BaseArgs & (AutomaticSpeechRecognitionInput | LegacyAudioInput);
|
|
14
5
|
/**
|
|
15
6
|
* This task reads some audio input and outputs the said words within the audio files.
|
|
16
7
|
* Recommended model (english language): facebook/wav2vec2-large-960h-lv60-self
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticSpeechRecognition.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/automaticSpeechRecognition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"automaticSpeechRecognition.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/automaticSpeechRecognition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AAGlE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,MAAM,MAAM,8BAA8B,GAAG,QAAQ,GAAG,CAAC,+BAA+B,GAAG,gBAAgB,CAAC,CAAC;AAC7G;;;GAGG;AACH,wBAAsB,0BAA0B,CAC/C,IAAI,EAAE,8BAA8B,EACpC,OAAO,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,gCAAgC,CAAC,CAW3C"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import type { TextToSpeechInput } from "@huggingface/tasks";
|
|
1
2
|
import type { BaseArgs, Options } from "../../types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The text to generate an audio from
|
|
5
|
-
*/
|
|
6
|
-
inputs: string;
|
|
7
|
-
};
|
|
8
|
-
export type TextToSpeechOutput = Blob;
|
|
3
|
+
type TextToSpeechArgs = BaseArgs & TextToSpeechInput;
|
|
9
4
|
/**
|
|
10
5
|
* This task synthesize an audio of a voice pronouncing a given text.
|
|
11
6
|
* Recommended model: espnet/kan-bayashi_ljspeech_vits
|
|
12
7
|
*/
|
|
13
|
-
export declare function textToSpeech(args: TextToSpeechArgs, options?: Options): Promise<
|
|
8
|
+
export declare function textToSpeech(args: TextToSpeechArgs, options?: Options): Promise<Blob>;
|
|
9
|
+
export {};
|
|
14
10
|
//# sourceMappingURL=textToSpeech.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textToSpeech.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/textToSpeech.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"textToSpeech.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/textToSpeech.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGrD,KAAK,gBAAgB,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAKrD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB3F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BaseArgs, RequestArgs } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated
|
|
4
|
+
*/
|
|
5
|
+
export interface LegacyAudioInput {
|
|
6
|
+
data: Blob | ArrayBuffer;
|
|
7
|
+
}
|
|
8
|
+
export declare function preparePayload(args: BaseArgs & ({
|
|
9
|
+
inputs: Blob;
|
|
10
|
+
} | LegacyAudioInput)): RequestArgs;
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,IAAI,GAAG,WAAW,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,GAAG,gBAAgB,CAAC,GAAG,WAAW,CAOlG"}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
+
import type { ImageClassificationInput, ImageClassificationOutput } from "@huggingface/tasks";
|
|
1
2
|
import type { BaseArgs, Options } from "../../types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Binary image data
|
|
5
|
-
*/
|
|
6
|
-
data: Blob | ArrayBuffer;
|
|
7
|
-
};
|
|
8
|
-
export interface ImageClassificationOutputValue {
|
|
9
|
-
/**
|
|
10
|
-
* The label for the class (model specific)
|
|
11
|
-
*/
|
|
12
|
-
label: string;
|
|
13
|
-
/**
|
|
14
|
-
* A float that represents how likely it is that the image file belongs to this class.
|
|
15
|
-
*/
|
|
16
|
-
score: number;
|
|
17
|
-
}
|
|
18
|
-
export type ImageClassificationOutput = ImageClassificationOutputValue[];
|
|
3
|
+
import { type LegacyImageInput } from "./utils";
|
|
4
|
+
export type ImageClassificationArgs = BaseArgs & (ImageClassificationInput | LegacyImageInput);
|
|
19
5
|
/**
|
|
20
6
|
* This task reads some image input and outputs the likelihood of classes.
|
|
21
7
|
* Recommended model: google/vit-base-patch16-224
|