@huggingface/inference 2.6.7 → 2.7.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 +126 -27
- package/dist/index.cjs +78 -12
- package/dist/index.js +76 -12
- package/dist/src/HfInference.d.ts +28 -0
- package/dist/src/HfInference.d.ts.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/InferenceOutputError.d.ts +4 -0
- package/dist/src/lib/InferenceOutputError.d.ts.map +1 -0
- package/dist/src/lib/getDefaultTask.d.ts +12 -0
- package/dist/src/lib/getDefaultTask.d.ts.map +1 -0
- package/dist/src/lib/isUrl.d.ts +2 -0
- package/dist/src/lib/isUrl.d.ts.map +1 -0
- package/dist/src/lib/makeRequestOptions.d.ts +18 -0
- package/dist/src/lib/makeRequestOptions.d.ts.map +1 -0
- package/dist/src/tasks/audio/audioClassification.d.ts +24 -0
- package/dist/src/tasks/audio/audioClassification.d.ts.map +1 -0
- package/dist/src/tasks/audio/audioToAudio.d.ts +28 -0
- package/dist/src/tasks/audio/audioToAudio.d.ts.map +1 -0
- package/dist/src/tasks/audio/automaticSpeechRecognition.d.ts +19 -0
- package/dist/src/tasks/audio/automaticSpeechRecognition.d.ts.map +1 -0
- package/dist/src/tasks/audio/textToSpeech.d.ts +14 -0
- package/dist/src/tasks/audio/textToSpeech.d.ts.map +1 -0
- package/dist/src/tasks/custom/request.d.ts +13 -0
- package/dist/src/tasks/custom/request.d.ts.map +1 -0
- package/dist/src/tasks/custom/streamingRequest.d.ts +13 -0
- package/dist/src/tasks/custom/streamingRequest.d.ts.map +1 -0
- package/dist/src/tasks/cv/imageClassification.d.ts +24 -0
- package/dist/src/tasks/cv/imageClassification.d.ts.map +1 -0
- package/dist/src/tasks/cv/imageSegmentation.d.ts +28 -0
- package/dist/src/tasks/cv/imageSegmentation.d.ts.map +1 -0
- package/dist/src/tasks/cv/imageToImage.d.ts +55 -0
- package/dist/src/tasks/cv/imageToImage.d.ts.map +1 -0
- package/dist/src/tasks/cv/imageToText.d.ts +18 -0
- package/dist/src/tasks/cv/imageToText.d.ts.map +1 -0
- package/dist/src/tasks/cv/objectDetection.d.ts +33 -0
- package/dist/src/tasks/cv/objectDetection.d.ts.map +1 -0
- package/dist/src/tasks/cv/textToImage.d.ts +36 -0
- package/dist/src/tasks/cv/textToImage.d.ts.map +1 -0
- package/dist/src/tasks/cv/zeroShotImageClassification.d.ts +26 -0
- package/dist/src/tasks/cv/zeroShotImageClassification.d.ts.map +1 -0
- package/dist/src/tasks/index.d.ts +32 -0
- package/dist/src/tasks/index.d.ts.map +1 -0
- package/dist/src/tasks/multimodal/documentQuestionAnswering.d.ts +35 -0
- package/dist/src/tasks/multimodal/documentQuestionAnswering.d.ts.map +1 -0
- package/dist/src/tasks/multimodal/visualQuestionAnswering.d.ts +27 -0
- package/dist/src/tasks/multimodal/visualQuestionAnswering.d.ts.map +1 -0
- package/dist/src/tasks/nlp/chatCompletion.d.ts +7 -0
- package/dist/src/tasks/nlp/chatCompletion.d.ts.map +1 -0
- package/dist/src/tasks/nlp/chatCompletionStream.d.ts +7 -0
- package/dist/src/tasks/nlp/chatCompletionStream.d.ts.map +1 -0
- package/dist/src/tasks/nlp/featureExtraction.d.ts +19 -0
- package/dist/src/tasks/nlp/featureExtraction.d.ts.map +1 -0
- package/dist/src/tasks/nlp/fillMask.d.ts +27 -0
- package/dist/src/tasks/nlp/fillMask.d.ts.map +1 -0
- package/dist/src/tasks/nlp/questionAnswering.d.ts +30 -0
- package/dist/src/tasks/nlp/questionAnswering.d.ts.map +1 -0
- package/dist/src/tasks/nlp/sentenceSimilarity.d.ts +19 -0
- package/dist/src/tasks/nlp/sentenceSimilarity.d.ts.map +1 -0
- package/dist/src/tasks/nlp/summarization.d.ts +48 -0
- package/dist/src/tasks/nlp/summarization.d.ts.map +1 -0
- package/dist/src/tasks/nlp/tableQuestionAnswering.d.ts +36 -0
- package/dist/src/tasks/nlp/tableQuestionAnswering.d.ts.map +1 -0
- package/dist/src/tasks/nlp/textClassification.d.ts +22 -0
- package/dist/src/tasks/nlp/textClassification.d.ts.map +1 -0
- package/dist/src/tasks/nlp/textGeneration.d.ts +8 -0
- package/dist/src/tasks/nlp/textGeneration.d.ts.map +1 -0
- package/dist/src/tasks/nlp/textGenerationStream.d.ts +81 -0
- package/dist/src/tasks/nlp/textGenerationStream.d.ts.map +1 -0
- package/dist/src/tasks/nlp/tokenClassification.d.ts +51 -0
- package/dist/src/tasks/nlp/tokenClassification.d.ts.map +1 -0
- package/dist/src/tasks/nlp/translation.d.ts +19 -0
- package/dist/src/tasks/nlp/translation.d.ts.map +1 -0
- package/dist/src/tasks/nlp/zeroShotClassification.d.ts +28 -0
- package/dist/src/tasks/nlp/zeroShotClassification.d.ts.map +1 -0
- package/dist/src/tasks/tabular/tabularClassification.d.ts +20 -0
- package/dist/src/tasks/tabular/tabularClassification.d.ts.map +1 -0
- package/dist/src/tasks/tabular/tabularRegression.d.ts +20 -0
- package/dist/src/tasks/tabular/tabularRegression.d.ts.map +1 -0
- package/dist/src/types.d.ts +69 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/base64FromBytes.d.ts +2 -0
- package/dist/src/utils/base64FromBytes.d.ts.map +1 -0
- package/dist/src/utils/distributive-omit.d.ts +9 -0
- package/dist/src/utils/distributive-omit.d.ts.map +1 -0
- package/dist/src/utils/isBackend.d.ts +2 -0
- package/dist/src/utils/isBackend.d.ts.map +1 -0
- package/dist/src/utils/isFrontend.d.ts +2 -0
- package/dist/src/utils/isFrontend.d.ts.map +1 -0
- package/dist/src/utils/omit.d.ts +5 -0
- package/dist/src/utils/omit.d.ts.map +1 -0
- package/dist/src/utils/pick.d.ts +5 -0
- package/dist/src/utils/pick.d.ts.map +1 -0
- package/dist/src/utils/toArray.d.ts +2 -0
- package/dist/src/utils/toArray.d.ts.map +1 -0
- package/dist/src/utils/typedInclude.d.ts +2 -0
- package/dist/src/utils/typedInclude.d.ts.map +1 -0
- package/dist/src/vendor/fetch-event-source/parse.d.ts +69 -0
- package/dist/src/vendor/fetch-event-source/parse.d.ts.map +1 -0
- package/dist/src/vendor/fetch-event-source/parse.spec.d.ts +2 -0
- package/dist/src/vendor/fetch-event-source/parse.spec.d.ts.map +1 -0
- package/dist/test/HfInference.spec.d.ts +2 -0
- package/dist/test/HfInference.spec.d.ts.map +1 -0
- package/dist/test/expect-closeto.d.ts +2 -0
- package/dist/test/expect-closeto.d.ts.map +1 -0
- package/dist/test/test-files.d.ts +2 -0
- package/dist/test/test-files.d.ts.map +1 -0
- package/dist/test/vcr.d.ts +2 -0
- package/dist/test/vcr.d.ts.map +1 -0
- package/package.json +9 -7
- package/src/HfInference.ts +4 -4
- package/src/lib/makeRequestOptions.ts +17 -7
- package/src/tasks/custom/request.ts +5 -0
- package/src/tasks/custom/streamingRequest.ts +8 -0
- package/src/tasks/cv/imageToImage.ts +1 -1
- package/src/tasks/cv/zeroShotImageClassification.ts +1 -1
- package/src/tasks/index.ts +2 -0
- package/src/tasks/multimodal/documentQuestionAnswering.ts +1 -1
- package/src/tasks/multimodal/visualQuestionAnswering.ts +1 -1
- package/src/tasks/nlp/chatCompletion.ts +32 -0
- package/src/tasks/nlp/chatCompletionStream.ts +17 -0
- package/src/tasks/nlp/textGeneration.ts +2 -202
- package/src/tasks/nlp/textGenerationStream.ts +2 -1
- package/src/types.ts +14 -3
- package/src/utils/base64FromBytes.ts +11 -0
- package/src/utils/{distributive-omit.d.ts → distributive-omit.ts} +0 -2
- package/src/utils/isBackend.ts +6 -0
- package/src/utils/isFrontend.ts +3 -0
- package/dist/index.d.ts +0 -1536
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function base64FromBytes(arr: Uint8Array): string {
|
|
2
|
+
if (globalThis.Buffer) {
|
|
3
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
4
|
+
} else {
|
|
5
|
+
const bin: string[] = [];
|
|
6
|
+
arr.forEach((byte) => {
|
|
7
|
+
bin.push(String.fromCharCode(byte));
|
|
8
|
+
});
|
|
9
|
+
return globalThis.btoa(bin.join(""));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* This allows omitting keys from objects inside unions, without merging the individual components of the union.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
type Keys<T> = keyof T;
|
|
8
|
-
type DistributiveKeys<T> = T extends unknown ? Keys<T> : never;
|
|
9
7
|
type Omit_<T, K> = Omit<T, Extract<keyof T, K>>;
|
|
10
8
|
|
|
11
9
|
export type DistributiveOmit<T, K> = T extends unknown
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
2
|
+
|
|
3
|
+
const isWebWorker =
|
|
4
|
+
typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
|
|
5
|
+
|
|
6
|
+
export const isBackend = !isBrowser && !isWebWorker;
|