@huggingface/inference 3.13.2 → 3.14.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/dist/{src → commonjs}/InferenceClient.d.ts +2 -2
- package/dist/commonjs/InferenceClient.d.ts.map +1 -0
- package/dist/commonjs/InferenceClient.js +83 -0
- package/dist/commonjs/config.js +6 -0
- package/dist/commonjs/index.d.ts +7 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +49 -0
- package/dist/commonjs/lib/InferenceOutputError.js +10 -0
- package/dist/commonjs/lib/getDefaultTask.js +48 -0
- package/dist/{src → commonjs}/lib/getInferenceProviderMapping.d.ts +1 -1
- package/dist/{src → commonjs}/lib/getInferenceProviderMapping.d.ts.map +1 -1
- package/dist/commonjs/lib/getInferenceProviderMapping.js +81 -0
- package/dist/{src → commonjs}/lib/getProviderHelper.d.ts +2 -2
- package/dist/{src → commonjs}/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/commonjs/lib/getProviderHelper.js +168 -0
- package/dist/commonjs/lib/isUrl.js +6 -0
- package/dist/{src → commonjs}/lib/makeRequestOptions.d.ts +3 -3
- package/dist/{src → commonjs}/lib/makeRequestOptions.d.ts.map +1 -1
- package/dist/commonjs/lib/makeRequestOptions.js +161 -0
- package/dist/commonjs/package.d.ts +3 -0
- package/dist/commonjs/package.d.ts.map +1 -0
- package/dist/commonjs/package.js +6 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/{src → commonjs}/providers/black-forest-labs.d.ts +2 -2
- package/dist/{src → commonjs}/providers/black-forest-labs.d.ts.map +1 -1
- package/dist/commonjs/providers/black-forest-labs.js +82 -0
- package/dist/{src → commonjs}/providers/cerebras.d.ts +1 -1
- package/dist/{src → commonjs}/providers/cerebras.d.ts.map +1 -1
- package/dist/commonjs/providers/cerebras.js +26 -0
- package/dist/{src → commonjs}/providers/cohere.d.ts +1 -1
- package/dist/{src → commonjs}/providers/cohere.d.ts.map +1 -1
- package/dist/commonjs/providers/cohere.js +29 -0
- package/dist/{src → commonjs}/providers/consts.d.ts +3 -3
- package/dist/commonjs/providers/consts.d.ts.map +1 -0
- package/dist/commonjs/providers/consts.js +35 -0
- package/dist/{src → commonjs}/providers/fal-ai.d.ts +3 -3
- package/dist/{src → commonjs}/providers/fal-ai.d.ts.map +1 -1
- package/dist/commonjs/providers/fal-ai.js +216 -0
- package/dist/{src → commonjs}/providers/featherless-ai.d.ts +2 -2
- package/dist/{src → commonjs}/providers/featherless-ai.d.ts.map +1 -1
- package/dist/commonjs/providers/featherless-ai.js +38 -0
- package/dist/{src → commonjs}/providers/fireworks-ai.d.ts +1 -1
- package/dist/commonjs/providers/fireworks-ai.d.ts.map +1 -0
- package/dist/commonjs/providers/fireworks-ai.js +29 -0
- package/dist/{src → commonjs}/providers/groq.d.ts +1 -1
- package/dist/{src → commonjs}/providers/groq.d.ts.map +1 -1
- package/dist/commonjs/providers/groq.js +39 -0
- package/dist/{src → commonjs}/providers/hf-inference.d.ts +6 -6
- package/dist/{src → commonjs}/providers/hf-inference.d.ts.map +1 -1
- package/dist/commonjs/providers/hf-inference.js +432 -0
- package/dist/{src → commonjs}/providers/hyperbolic.d.ts +2 -2
- package/dist/{src → commonjs}/providers/hyperbolic.d.ts.map +1 -1
- package/dist/commonjs/providers/hyperbolic.js +78 -0
- package/dist/{src → commonjs}/providers/nebius.d.ts +2 -2
- package/dist/{src → commonjs}/providers/nebius.d.ts.map +1 -1
- package/dist/commonjs/providers/nebius.js +70 -0
- package/dist/{src → commonjs}/providers/novita.d.ts +2 -2
- package/dist/{src → commonjs}/providers/novita.d.ts.map +1 -1
- package/dist/commonjs/providers/novita.js +73 -0
- package/dist/{src → commonjs}/providers/nscale.d.ts +2 -2
- package/dist/{src → commonjs}/providers/nscale.d.ts.map +1 -1
- package/dist/commonjs/providers/nscale.js +46 -0
- package/dist/{src → commonjs}/providers/openai.d.ts +1 -1
- package/dist/{src → commonjs}/providers/openai.d.ts.map +1 -1
- package/dist/commonjs/providers/openai.js +15 -0
- package/dist/{src → commonjs}/providers/ovhcloud.d.ts +2 -2
- package/dist/{src → commonjs}/providers/ovhcloud.d.ts.map +1 -1
- package/dist/commonjs/providers/ovhcloud.js +60 -0
- package/dist/{src → commonjs}/providers/providerHelper.d.ts +4 -4
- package/dist/{src → commonjs}/providers/providerHelper.d.ts.map +1 -1
- package/dist/commonjs/providers/providerHelper.js +108 -0
- package/dist/{src → commonjs}/providers/replicate.d.ts +2 -2
- package/dist/{src → commonjs}/providers/replicate.d.ts.map +1 -1
- package/dist/commonjs/providers/replicate.js +135 -0
- package/dist/{src → commonjs}/providers/sambanova.d.ts +3 -3
- package/dist/{src → commonjs}/providers/sambanova.d.ts.map +1 -1
- package/dist/commonjs/providers/sambanova.js +49 -0
- package/dist/{src → commonjs}/providers/together.d.ts +2 -2
- package/dist/{src → commonjs}/providers/together.d.ts.map +1 -1
- package/dist/commonjs/providers/together.js +71 -0
- package/dist/{src → commonjs}/snippets/getInferenceSnippets.d.ts +2 -2
- package/dist/{src → commonjs}/snippets/getInferenceSnippets.d.ts.map +1 -1
- package/dist/commonjs/snippets/getInferenceSnippets.js +312 -0
- package/dist/commonjs/snippets/index.js +5 -0
- package/dist/commonjs/snippets/templates.exported.js +81 -0
- package/dist/{src → commonjs}/tasks/audio/audioClassification.d.ts +2 -2
- package/dist/{src → commonjs}/tasks/audio/audioClassification.d.ts.map +1 -1
- package/dist/commonjs/tasks/audio/audioClassification.js +21 -0
- package/dist/{src → commonjs}/tasks/audio/audioToAudio.d.ts +2 -2
- package/dist/commonjs/tasks/audio/audioToAudio.d.ts.map +1 -0
- package/dist/commonjs/tasks/audio/audioToAudio.js +22 -0
- package/dist/{src → commonjs}/tasks/audio/automaticSpeechRecognition.d.ts +2 -2
- package/dist/commonjs/tasks/audio/automaticSpeechRecognition.d.ts.map +1 -0
- package/dist/commonjs/tasks/audio/automaticSpeechRecognition.js +25 -0
- package/dist/{src → commonjs}/tasks/audio/textToSpeech.d.ts +1 -1
- package/dist/commonjs/tasks/audio/textToSpeech.d.ts.map +1 -0
- package/dist/commonjs/tasks/audio/textToSpeech.js +19 -0
- package/dist/{src → commonjs}/tasks/audio/utils.d.ts +1 -1
- package/dist/commonjs/tasks/audio/utils.d.ts.map +1 -0
- package/dist/commonjs/tasks/audio/utils.js +12 -0
- package/dist/{src → commonjs}/tasks/custom/request.d.ts +1 -1
- package/dist/commonjs/tasks/custom/request.d.ts.map +1 -0
- package/dist/commonjs/tasks/custom/request.js +17 -0
- package/dist/{src → commonjs}/tasks/custom/streamingRequest.d.ts +1 -1
- package/dist/commonjs/tasks/custom/streamingRequest.d.ts.map +1 -0
- package/dist/commonjs/tasks/custom/streamingRequest.js +16 -0
- package/dist/{src → commonjs}/tasks/cv/imageClassification.d.ts +2 -2
- package/dist/commonjs/tasks/cv/imageClassification.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/imageClassification.js +21 -0
- package/dist/{src → commonjs}/tasks/cv/imageSegmentation.d.ts +2 -2
- package/dist/commonjs/tasks/cv/imageSegmentation.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/imageSegmentation.js +21 -0
- package/dist/{src → commonjs}/tasks/cv/imageToImage.d.ts +1 -1
- package/dist/commonjs/tasks/cv/imageToImage.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/imageToImage.js +20 -0
- package/dist/{src → commonjs}/tasks/cv/imageToText.d.ts +2 -2
- package/dist/commonjs/tasks/cv/imageToText.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/imageToText.js +20 -0
- package/dist/{src → commonjs}/tasks/cv/objectDetection.d.ts +2 -2
- package/dist/commonjs/tasks/cv/objectDetection.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/objectDetection.js +21 -0
- package/dist/{src → commonjs}/tasks/cv/textToImage.d.ts +1 -1
- package/dist/commonjs/tasks/cv/textToImage.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/textToImage.js +17 -0
- package/dist/{src → commonjs}/tasks/cv/textToVideo.d.ts +1 -1
- package/dist/commonjs/tasks/cv/textToVideo.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/textToVideo.js +17 -0
- package/dist/{src → commonjs}/tasks/cv/utils.d.ts +1 -1
- package/dist/commonjs/tasks/cv/utils.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/utils.js +7 -0
- package/dist/{src → commonjs}/tasks/cv/zeroShotImageClassification.d.ts +1 -1
- package/dist/commonjs/tasks/cv/zeroShotImageClassification.d.ts.map +1 -0
- package/dist/commonjs/tasks/cv/zeroShotImageClassification.js +39 -0
- package/dist/commonjs/tasks/index.d.ts +33 -0
- package/dist/commonjs/tasks/index.d.ts.map +1 -0
- package/dist/commonjs/tasks/index.js +54 -0
- package/dist/{src → commonjs}/tasks/multimodal/documentQuestionAnswering.d.ts +1 -1
- package/dist/commonjs/tasks/multimodal/documentQuestionAnswering.d.ts.map +1 -0
- package/dist/commonjs/tasks/multimodal/documentQuestionAnswering.js +27 -0
- package/dist/{src → commonjs}/tasks/multimodal/visualQuestionAnswering.d.ts +1 -1
- package/dist/commonjs/tasks/multimodal/visualQuestionAnswering.d.ts.map +1 -0
- package/dist/commonjs/tasks/multimodal/visualQuestionAnswering.js +27 -0
- package/dist/{src → commonjs}/tasks/nlp/chatCompletion.d.ts +1 -1
- package/dist/{src → commonjs}/tasks/nlp/chatCompletion.d.ts.map +1 -1
- package/dist/commonjs/tasks/nlp/chatCompletion.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/chatCompletionStream.d.ts +1 -1
- package/dist/{src → commonjs}/tasks/nlp/chatCompletionStream.d.ts.map +1 -1
- package/dist/commonjs/tasks/nlp/chatCompletionStream.js +17 -0
- package/dist/{src → commonjs}/tasks/nlp/featureExtraction.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/featureExtraction.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/featureExtraction.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/fillMask.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/fillMask.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/fillMask.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/questionAnswering.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/questionAnswering.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/questionAnswering.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/sentenceSimilarity.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/sentenceSimilarity.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/sentenceSimilarity.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/summarization.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/summarization.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/summarization.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/tableQuestionAnswering.d.ts +1 -1
- package/dist/{src → commonjs}/tasks/nlp/tableQuestionAnswering.d.ts.map +1 -1
- package/dist/commonjs/tasks/nlp/tableQuestionAnswering.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/textClassification.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/textClassification.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/textClassification.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/textGeneration.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/textGeneration.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/textGeneration.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/textGenerationStream.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/textGenerationStream.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/textGenerationStream.js +17 -0
- package/dist/{src → commonjs}/tasks/nlp/tokenClassification.d.ts +1 -1
- package/dist/{src → commonjs}/tasks/nlp/tokenClassification.d.ts.map +1 -1
- package/dist/commonjs/tasks/nlp/tokenClassification.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/translation.d.ts +1 -1
- package/dist/commonjs/tasks/nlp/translation.d.ts.map +1 -0
- package/dist/commonjs/tasks/nlp/translation.js +18 -0
- package/dist/{src → commonjs}/tasks/nlp/zeroShotClassification.d.ts +1 -1
- package/dist/{src → commonjs}/tasks/nlp/zeroShotClassification.d.ts.map +1 -1
- package/dist/commonjs/tasks/nlp/zeroShotClassification.js +18 -0
- package/dist/{src → commonjs}/tasks/tabular/tabularClassification.d.ts +1 -1
- package/dist/commonjs/tasks/tabular/tabularClassification.d.ts.map +1 -0
- package/dist/commonjs/tasks/tabular/tabularClassification.js +20 -0
- package/dist/{src → commonjs}/tasks/tabular/tabularRegression.d.ts +1 -1
- package/dist/commonjs/tasks/tabular/tabularRegression.d.ts.map +1 -0
- package/dist/commonjs/tasks/tabular/tabularRegression.js +20 -0
- package/dist/{src → commonjs}/types.d.ts +1 -1
- package/dist/{src → commonjs}/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +23 -0
- package/dist/commonjs/utils/base64FromBytes.js +15 -0
- package/dist/commonjs/utils/delay.js +8 -0
- package/dist/commonjs/utils/distributive-omit.js +7 -0
- package/dist/commonjs/utils/isBackend.js +6 -0
- package/dist/commonjs/utils/isFrontend.js +5 -0
- package/dist/commonjs/utils/omit.js +13 -0
- package/dist/commonjs/utils/pick.js +13 -0
- package/dist/{src → commonjs}/utils/request.d.ts +2 -2
- package/dist/{src → commonjs}/utils/request.d.ts.map +1 -1
- package/dist/commonjs/utils/request.js +116 -0
- package/dist/commonjs/utils/toArray.js +9 -0
- package/dist/commonjs/utils/typedEntries.js +6 -0
- package/dist/commonjs/utils/typedInclude.js +6 -0
- package/dist/commonjs/vendor/fetch-event-source/parse.d.ts.map +1 -0
- package/dist/commonjs/vendor/fetch-event-source/parse.js +185 -0
- package/dist/commonjs/vendor/fetch-event-source/parse.spec.js +370 -0
- package/dist/esm/InferenceClient.d.ts +32 -0
- package/dist/esm/InferenceClient.d.ts.map +1 -0
- package/dist/esm/InferenceClient.js +44 -0
- package/dist/esm/config.d.ts +4 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/config.js +3 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/{src/index.d.ts → esm/index.js} +4 -5
- package/dist/esm/lib/InferenceOutputError.d.ts +4 -0
- package/dist/esm/lib/InferenceOutputError.d.ts.map +1 -0
- package/dist/esm/lib/InferenceOutputError.js +6 -0
- package/dist/esm/lib/getDefaultTask.d.ts +11 -0
- package/dist/esm/lib/getDefaultTask.d.ts.map +1 -0
- package/dist/esm/lib/getDefaultTask.js +45 -0
- package/dist/esm/lib/getInferenceProviderMapping.d.ts +25 -0
- package/dist/esm/lib/getInferenceProviderMapping.d.ts.map +1 -0
- package/dist/esm/lib/getInferenceProviderMapping.js +75 -0
- package/dist/esm/lib/getProviderHelper.d.ts +37 -0
- package/dist/esm/lib/getProviderHelper.d.ts.map +1 -0
- package/dist/esm/lib/getProviderHelper.js +131 -0
- package/dist/esm/lib/isUrl.d.ts +2 -0
- package/dist/esm/lib/isUrl.d.ts.map +1 -0
- package/dist/esm/lib/isUrl.js +3 -0
- package/dist/esm/lib/makeRequestOptions.d.ts +31 -0
- package/dist/esm/lib/makeRequestOptions.d.ts.map +1 -0
- package/dist/esm/lib/makeRequestOptions.js +157 -0
- package/dist/esm/package.d.ts +3 -0
- package/dist/esm/package.d.ts.map +1 -0
- package/dist/esm/package.js +3 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/providers/black-forest-labs.d.ts +15 -0
- package/dist/esm/providers/black-forest-labs.d.ts.map +1 -0
- package/dist/esm/providers/black-forest-labs.js +78 -0
- package/dist/esm/providers/cerebras.d.ts +21 -0
- package/dist/esm/providers/cerebras.d.ts.map +1 -0
- package/dist/esm/providers/cerebras.js +22 -0
- package/dist/esm/providers/cohere.d.ts +22 -0
- package/dist/esm/providers/cohere.d.ts.map +1 -0
- package/dist/esm/providers/cohere.js +25 -0
- package/dist/esm/providers/consts.d.ts +12 -0
- package/dist/esm/providers/consts.d.ts.map +1 -0
- package/dist/esm/providers/consts.js +32 -0
- package/dist/esm/providers/fal-ai.d.ts +42 -0
- package/dist/esm/providers/fal-ai.d.ts.map +1 -0
- package/dist/esm/providers/fal-ai.js +209 -0
- package/dist/esm/providers/featherless-ai.d.ts +22 -0
- package/dist/esm/providers/featherless-ai.d.ts.map +1 -0
- package/dist/esm/providers/featherless-ai.js +33 -0
- package/dist/esm/providers/fireworks-ai.d.ts +22 -0
- package/dist/esm/providers/fireworks-ai.d.ts.map +1 -0
- package/dist/esm/providers/fireworks-ai.js +25 -0
- package/dist/esm/providers/groq.d.ts +10 -0
- package/dist/esm/providers/groq.d.ts.map +1 -0
- package/dist/esm/providers/groq.js +34 -0
- package/dist/esm/providers/hf-inference.d.ts +131 -0
- package/dist/esm/providers/hf-inference.d.ts.map +1 -0
- package/dist/esm/providers/hf-inference.js +400 -0
- package/dist/esm/providers/hyperbolic.d.ts +48 -0
- package/dist/esm/providers/hyperbolic.d.ts.map +1 -0
- package/dist/esm/providers/hyperbolic.js +72 -0
- package/dist/esm/providers/nebius.d.ts +49 -0
- package/dist/esm/providers/nebius.d.ts.map +1 -0
- package/dist/esm/providers/nebius.js +63 -0
- package/dist/esm/providers/novita.d.ts +22 -0
- package/dist/esm/providers/novita.d.ts.map +1 -0
- package/dist/esm/providers/novita.js +67 -0
- package/dist/esm/providers/nscale.d.ts +35 -0
- package/dist/esm/providers/nscale.d.ts.map +1 -0
- package/dist/esm/providers/nscale.js +41 -0
- package/dist/esm/providers/openai.d.ts +8 -0
- package/dist/esm/providers/openai.d.ts.map +1 -0
- package/dist/esm/providers/openai.js +11 -0
- package/dist/esm/providers/ovhcloud.d.ts +38 -0
- package/dist/esm/providers/ovhcloud.d.ts.map +1 -0
- package/dist/esm/providers/ovhcloud.js +55 -0
- package/dist/esm/providers/providerHelper.d.ts +186 -0
- package/dist/esm/providers/providerHelper.d.ts.map +1 -0
- package/dist/esm/providers/providerHelper.js +102 -0
- package/dist/esm/providers/replicate.d.ts +25 -0
- package/dist/esm/providers/replicate.d.ts.map +1 -0
- package/dist/esm/providers/replicate.js +129 -0
- package/dist/esm/providers/sambanova.d.ts +14 -0
- package/dist/esm/providers/sambanova.d.ts.map +1 -0
- package/dist/esm/providers/sambanova.js +44 -0
- package/dist/esm/providers/together.d.ts +49 -0
- package/dist/esm/providers/together.d.ts.map +1 -0
- package/dist/esm/providers/together.js +65 -0
- package/dist/esm/snippets/getInferenceSnippets.d.ts +9 -0
- package/dist/esm/snippets/getInferenceSnippets.d.ts.map +1 -0
- package/dist/esm/snippets/getInferenceSnippets.js +309 -0
- package/dist/esm/snippets/index.d.ts +2 -0
- package/dist/esm/snippets/index.d.ts.map +1 -0
- package/dist/esm/snippets/index.js +1 -0
- package/dist/esm/snippets/templates.exported.d.ts +2 -0
- package/dist/esm/snippets/templates.exported.d.ts.map +1 -0
- package/dist/esm/snippets/templates.exported.js +78 -0
- package/dist/esm/tasks/audio/audioClassification.d.ts +10 -0
- package/dist/esm/tasks/audio/audioClassification.d.ts.map +1 -0
- package/dist/esm/tasks/audio/audioClassification.js +18 -0
- package/dist/esm/tasks/audio/audioToAudio.d.ts +29 -0
- package/dist/esm/tasks/audio/audioToAudio.d.ts.map +1 -0
- package/dist/esm/tasks/audio/audioToAudio.js +19 -0
- package/dist/esm/tasks/audio/automaticSpeechRecognition.d.ts +10 -0
- package/dist/esm/tasks/audio/automaticSpeechRecognition.d.ts.map +1 -0
- package/dist/esm/tasks/audio/automaticSpeechRecognition.js +22 -0
- package/dist/esm/tasks/audio/textToSpeech.d.ts +10 -0
- package/dist/esm/tasks/audio/textToSpeech.d.ts.map +1 -0
- package/dist/esm/tasks/audio/textToSpeech.js +16 -0
- package/dist/esm/tasks/audio/utils.d.ts +12 -0
- package/dist/esm/tasks/audio/utils.d.ts.map +1 -0
- package/dist/esm/tasks/audio/utils.js +9 -0
- package/dist/esm/tasks/custom/request.d.ts +10 -0
- package/dist/esm/tasks/custom/request.d.ts.map +1 -0
- package/dist/esm/tasks/custom/request.js +14 -0
- package/dist/esm/tasks/custom/streamingRequest.d.ts +10 -0
- package/dist/esm/tasks/custom/streamingRequest.d.ts.map +1 -0
- package/dist/esm/tasks/custom/streamingRequest.js +13 -0
- package/dist/esm/tasks/cv/imageClassification.d.ts +10 -0
- package/dist/esm/tasks/cv/imageClassification.d.ts.map +1 -0
- package/dist/esm/tasks/cv/imageClassification.js +18 -0
- package/dist/esm/tasks/cv/imageSegmentation.d.ts +10 -0
- package/dist/esm/tasks/cv/imageSegmentation.d.ts.map +1 -0
- package/dist/esm/tasks/cv/imageSegmentation.js +18 -0
- package/dist/esm/tasks/cv/imageToImage.d.ts +9 -0
- package/dist/esm/tasks/cv/imageToImage.d.ts.map +1 -0
- package/dist/esm/tasks/cv/imageToImage.js +17 -0
- package/dist/esm/tasks/cv/imageToText.d.ts +9 -0
- package/dist/esm/tasks/cv/imageToText.d.ts.map +1 -0
- package/dist/esm/tasks/cv/imageToText.js +17 -0
- package/dist/esm/tasks/cv/objectDetection.d.ts +10 -0
- package/dist/esm/tasks/cv/objectDetection.d.ts.map +1 -0
- package/dist/esm/tasks/cv/objectDetection.js +18 -0
- package/dist/esm/tasks/cv/textToImage.d.ts +18 -0
- package/dist/esm/tasks/cv/textToImage.d.ts.map +1 -0
- package/dist/esm/tasks/cv/textToImage.js +14 -0
- package/dist/esm/tasks/cv/textToVideo.d.ts +6 -0
- package/dist/esm/tasks/cv/textToVideo.d.ts.map +1 -0
- package/dist/esm/tasks/cv/textToVideo.js +14 -0
- package/dist/esm/tasks/cv/utils.d.ts +11 -0
- package/dist/esm/tasks/cv/utils.d.ts.map +1 -0
- package/dist/esm/tasks/cv/utils.js +4 -0
- package/dist/esm/tasks/cv/zeroShotImageClassification.d.ts +18 -0
- package/dist/esm/tasks/cv/zeroShotImageClassification.d.ts.map +1 -0
- package/dist/esm/tasks/cv/zeroShotImageClassification.js +36 -0
- package/dist/esm/tasks/index.d.ts +33 -0
- package/dist/esm/tasks/index.d.ts.map +1 -0
- package/dist/esm/tasks/index.js +38 -0
- package/dist/esm/tasks/multimodal/documentQuestionAnswering.d.ts +12 -0
- package/dist/esm/tasks/multimodal/documentQuestionAnswering.d.ts.map +1 -0
- package/dist/esm/tasks/multimodal/documentQuestionAnswering.js +24 -0
- package/dist/esm/tasks/multimodal/visualQuestionAnswering.d.ts +12 -0
- package/dist/esm/tasks/multimodal/visualQuestionAnswering.d.ts.map +1 -0
- package/dist/esm/tasks/multimodal/visualQuestionAnswering.js +24 -0
- package/dist/esm/tasks/nlp/chatCompletion.d.ts +7 -0
- package/dist/esm/tasks/nlp/chatCompletion.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/chatCompletion.js +15 -0
- package/dist/esm/tasks/nlp/chatCompletionStream.d.ts +7 -0
- package/dist/esm/tasks/nlp/chatCompletionStream.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/chatCompletionStream.js +14 -0
- package/dist/esm/tasks/nlp/featureExtraction.d.ts +17 -0
- package/dist/esm/tasks/nlp/featureExtraction.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/featureExtraction.js +15 -0
- package/dist/esm/tasks/nlp/fillMask.d.ts +8 -0
- package/dist/esm/tasks/nlp/fillMask.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/fillMask.js +15 -0
- package/dist/esm/tasks/nlp/questionAnswering.d.ts +8 -0
- package/dist/esm/tasks/nlp/questionAnswering.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/questionAnswering.js +15 -0
- package/dist/esm/tasks/nlp/sentenceSimilarity.d.ts +8 -0
- package/dist/esm/tasks/nlp/sentenceSimilarity.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/sentenceSimilarity.js +15 -0
- package/dist/esm/tasks/nlp/summarization.d.ts +8 -0
- package/dist/esm/tasks/nlp/summarization.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/summarization.js +15 -0
- package/dist/esm/tasks/nlp/tableQuestionAnswering.d.ts +8 -0
- package/dist/esm/tasks/nlp/tableQuestionAnswering.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/tableQuestionAnswering.js +15 -0
- package/dist/esm/tasks/nlp/textClassification.d.ts +8 -0
- package/dist/esm/tasks/nlp/textClassification.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/textClassification.js +15 -0
- package/dist/esm/tasks/nlp/textGeneration.d.ts +8 -0
- package/dist/esm/tasks/nlp/textGeneration.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/textGeneration.js +15 -0
- package/dist/esm/tasks/nlp/textGenerationStream.d.ts +81 -0
- package/dist/esm/tasks/nlp/textGenerationStream.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/textGenerationStream.js +14 -0
- package/dist/esm/tasks/nlp/tokenClassification.d.ts +8 -0
- package/dist/esm/tasks/nlp/tokenClassification.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/tokenClassification.js +15 -0
- package/dist/esm/tasks/nlp/translation.d.ts +8 -0
- package/dist/esm/tasks/nlp/translation.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/translation.js +15 -0
- package/dist/esm/tasks/nlp/zeroShotClassification.d.ts +8 -0
- package/dist/esm/tasks/nlp/zeroShotClassification.d.ts.map +1 -0
- package/dist/esm/tasks/nlp/zeroShotClassification.js +15 -0
- package/dist/esm/tasks/tabular/tabularClassification.d.ts +20 -0
- package/dist/esm/tasks/tabular/tabularClassification.d.ts.map +1 -0
- package/dist/esm/tasks/tabular/tabularClassification.js +17 -0
- package/dist/esm/tasks/tabular/tabularRegression.d.ts +20 -0
- package/dist/esm/tasks/tabular/tabularRegression.d.ts.map +1 -0
- package/dist/esm/tasks/tabular/tabularRegression.js +17 -0
- package/dist/esm/types.d.ts +97 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +20 -0
- package/dist/esm/utils/base64FromBytes.d.ts +2 -0
- package/dist/esm/utils/base64FromBytes.d.ts.map +1 -0
- package/dist/esm/utils/base64FromBytes.js +12 -0
- package/dist/esm/utils/delay.d.ts +2 -0
- package/dist/esm/utils/delay.d.ts.map +1 -0
- package/dist/esm/utils/delay.js +5 -0
- package/dist/esm/utils/distributive-omit.d.ts +9 -0
- package/dist/esm/utils/distributive-omit.d.ts.map +1 -0
- package/dist/esm/utils/distributive-omit.js +6 -0
- package/dist/esm/utils/isBackend.d.ts +2 -0
- package/dist/esm/utils/isBackend.d.ts.map +1 -0
- package/dist/esm/utils/isBackend.js +3 -0
- package/dist/esm/utils/isFrontend.d.ts +2 -0
- package/dist/esm/utils/isFrontend.d.ts.map +1 -0
- package/dist/esm/utils/isFrontend.js +2 -0
- package/dist/esm/utils/omit.d.ts +5 -0
- package/dist/esm/utils/omit.d.ts.map +1 -0
- package/dist/esm/utils/omit.js +10 -0
- package/dist/esm/utils/pick.d.ts +5 -0
- package/dist/esm/utils/pick.d.ts.map +1 -0
- package/dist/esm/utils/pick.js +10 -0
- package/dist/esm/utils/request.d.ts +28 -0
- package/dist/esm/utils/request.d.ts.map +1 -0
- package/dist/esm/utils/request.js +112 -0
- package/dist/esm/utils/toArray.d.ts +2 -0
- package/dist/esm/utils/toArray.d.ts.map +1 -0
- package/dist/esm/utils/toArray.js +6 -0
- package/dist/esm/utils/typedEntries.d.ts +4 -0
- package/dist/esm/utils/typedEntries.d.ts.map +1 -0
- package/dist/esm/utils/typedEntries.js +3 -0
- package/dist/esm/utils/typedInclude.d.ts +2 -0
- package/dist/esm/utils/typedInclude.d.ts.map +1 -0
- package/dist/esm/utils/typedInclude.js +3 -0
- package/dist/esm/vendor/fetch-event-source/parse.d.ts +69 -0
- package/dist/esm/vendor/fetch-event-source/parse.d.ts.map +1 -0
- package/dist/esm/vendor/fetch-event-source/parse.js +180 -0
- package/dist/esm/vendor/fetch-event-source/parse.spec.d.ts +2 -0
- package/dist/esm/vendor/fetch-event-source/parse.spec.d.ts.map +1 -0
- package/dist/esm/vendor/fetch-event-source/parse.spec.js +335 -0
- package/package.json +26 -12
- package/src/InferenceClient.ts +4 -4
- package/src/index.ts +4 -4
- package/src/lib/getDefaultTask.ts +2 -2
- package/src/lib/getInferenceProviderMapping.ts +5 -5
- package/src/lib/getProviderHelper.ts +19 -19
- package/src/lib/makeRequestOptions.ts +8 -8
- package/src/package.ts +3 -0
- package/src/providers/black-forest-labs.ts +5 -5
- package/src/providers/cerebras.ts +1 -1
- package/src/providers/cohere.ts +1 -1
- package/src/providers/consts.ts +3 -3
- package/src/providers/fal-ai.ts +9 -9
- package/src/providers/featherless-ai.ts +3 -3
- package/src/providers/fireworks-ai.ts +1 -1
- package/src/providers/groq.ts +1 -1
- package/src/providers/hf-inference.ts +11 -11
- package/src/providers/hyperbolic.ts +4 -4
- package/src/providers/nebius.ts +4 -4
- package/src/providers/novita.ts +5 -5
- package/src/providers/nscale.ts +4 -4
- package/src/providers/openai.ts +1 -1
- package/src/providers/ovhcloud.ts +4 -4
- package/src/providers/providerHelper.ts +7 -7
- package/src/providers/replicate.ts +5 -5
- package/src/providers/sambanova.ts +4 -4
- package/src/providers/together.ts +4 -4
- package/src/snippets/getInferenceSnippets.ts +7 -7
- package/src/tasks/audio/audioClassification.ts +6 -6
- package/src/tasks/audio/audioToAudio.ts +6 -6
- package/src/tasks/audio/automaticSpeechRecognition.ts +6 -6
- package/src/tasks/audio/textToSpeech.ts +4 -4
- package/src/tasks/audio/utils.ts +2 -2
- package/src/tasks/custom/request.ts +4 -4
- package/src/tasks/custom/streamingRequest.ts +4 -4
- package/src/tasks/cv/imageClassification.ts +5 -5
- package/src/tasks/cv/imageSegmentation.ts +5 -5
- package/src/tasks/cv/imageToImage.ts +4 -4
- package/src/tasks/cv/imageToText.ts +6 -6
- package/src/tasks/cv/objectDetection.ts +5 -5
- package/src/tasks/cv/textToImage.ts +5 -5
- package/src/tasks/cv/textToVideo.ts +8 -8
- package/src/tasks/cv/utils.ts +2 -2
- package/src/tasks/cv/zeroShotImageClassification.ts +5 -5
- package/src/tasks/index.ts +32 -32
- package/src/tasks/multimodal/documentQuestionAnswering.ts +5 -5
- package/src/tasks/multimodal/visualQuestionAnswering.ts +5 -5
- package/src/tasks/nlp/chatCompletion.ts +4 -4
- package/src/tasks/nlp/chatCompletionStream.ts +4 -4
- package/src/tasks/nlp/featureExtraction.ts +4 -4
- package/src/tasks/nlp/fillMask.ts +4 -4
- package/src/tasks/nlp/questionAnswering.ts +4 -4
- package/src/tasks/nlp/sentenceSimilarity.ts +4 -4
- package/src/tasks/nlp/summarization.ts +4 -4
- package/src/tasks/nlp/tableQuestionAnswering.ts +4 -4
- package/src/tasks/nlp/textClassification.ts +4 -4
- package/src/tasks/nlp/textGeneration.ts +5 -5
- package/src/tasks/nlp/textGenerationStream.ts +4 -4
- package/src/tasks/nlp/tokenClassification.ts +4 -4
- package/src/tasks/nlp/translation.ts +4 -4
- package/src/tasks/nlp/zeroShotClassification.ts +4 -4
- package/src/tasks/tabular/tabularClassification.ts +4 -4
- package/src/tasks/tabular/tabularRegression.ts +4 -4
- package/src/types.ts +1 -1
- package/src/utils/isFrontend.ts +1 -1
- package/src/utils/omit.ts +2 -2
- package/src/utils/request.ts +5 -5
- package/src/vendor/fetch-event-source/parse.spec.ts +1 -1
- package/src/vendor/fetch-event-source/parse.ts +6 -5
- package/dist/index.cjs +0 -2868
- package/dist/index.js +0 -2812
- package/dist/src/InferenceClient.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/providers/consts.d.ts.map +0 -1
- package/dist/src/providers/fireworks-ai.d.ts.map +0 -1
- package/dist/src/tasks/audio/audioToAudio.d.ts.map +0 -1
- package/dist/src/tasks/audio/automaticSpeechRecognition.d.ts.map +0 -1
- package/dist/src/tasks/audio/textToSpeech.d.ts.map +0 -1
- package/dist/src/tasks/audio/utils.d.ts.map +0 -1
- package/dist/src/tasks/custom/request.d.ts.map +0 -1
- package/dist/src/tasks/custom/streamingRequest.d.ts.map +0 -1
- package/dist/src/tasks/cv/imageClassification.d.ts.map +0 -1
- package/dist/src/tasks/cv/imageSegmentation.d.ts.map +0 -1
- package/dist/src/tasks/cv/imageToImage.d.ts.map +0 -1
- package/dist/src/tasks/cv/imageToText.d.ts.map +0 -1
- package/dist/src/tasks/cv/objectDetection.d.ts.map +0 -1
- package/dist/src/tasks/cv/textToImage.d.ts.map +0 -1
- package/dist/src/tasks/cv/textToVideo.d.ts.map +0 -1
- package/dist/src/tasks/cv/utils.d.ts.map +0 -1
- package/dist/src/tasks/cv/zeroShotImageClassification.d.ts.map +0 -1
- package/dist/src/tasks/index.d.ts +0 -33
- package/dist/src/tasks/index.d.ts.map +0 -1
- package/dist/src/tasks/multimodal/documentQuestionAnswering.d.ts.map +0 -1
- package/dist/src/tasks/multimodal/visualQuestionAnswering.d.ts.map +0 -1
- package/dist/src/tasks/nlp/featureExtraction.d.ts.map +0 -1
- package/dist/src/tasks/nlp/fillMask.d.ts.map +0 -1
- package/dist/src/tasks/nlp/questionAnswering.d.ts.map +0 -1
- package/dist/src/tasks/nlp/sentenceSimilarity.d.ts.map +0 -1
- package/dist/src/tasks/nlp/summarization.d.ts.map +0 -1
- package/dist/src/tasks/nlp/textClassification.d.ts.map +0 -1
- package/dist/src/tasks/nlp/textGeneration.d.ts.map +0 -1
- package/dist/src/tasks/nlp/textGenerationStream.d.ts.map +0 -1
- package/dist/src/tasks/nlp/translation.d.ts.map +0 -1
- package/dist/src/tasks/tabular/tabularClassification.d.ts.map +0 -1
- package/dist/src/tasks/tabular/tabularRegression.d.ts.map +0 -1
- package/dist/src/vendor/fetch-event-source/parse.d.ts.map +0 -1
- package/dist/test/InferenceClient.spec.d.ts +0 -2
- package/dist/test/InferenceClient.spec.d.ts.map +0 -1
- package/dist/test/expect-closeto.d.ts +0 -2
- package/dist/test/expect-closeto.d.ts.map +0 -1
- package/dist/test/test-files.d.ts +0 -2
- package/dist/test/test-files.d.ts.map +0 -1
- /package/dist/{src → commonjs}/config.d.ts +0 -0
- /package/dist/{src → commonjs}/config.d.ts.map +0 -0
- /package/dist/{src → commonjs}/lib/InferenceOutputError.d.ts +0 -0
- /package/dist/{src → commonjs}/lib/InferenceOutputError.d.ts.map +0 -0
- /package/dist/{src → commonjs}/lib/getDefaultTask.d.ts +0 -0
- /package/dist/{src → commonjs}/lib/getDefaultTask.d.ts.map +0 -0
- /package/dist/{src → commonjs}/lib/isUrl.d.ts +0 -0
- /package/dist/{src → commonjs}/lib/isUrl.d.ts.map +0 -0
- /package/dist/{src → commonjs}/snippets/index.d.ts +0 -0
- /package/dist/{src → commonjs}/snippets/index.d.ts.map +0 -0
- /package/dist/{src → commonjs}/snippets/templates.exported.d.ts +0 -0
- /package/dist/{src → commonjs}/snippets/templates.exported.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/base64FromBytes.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/base64FromBytes.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/delay.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/delay.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/distributive-omit.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/distributive-omit.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/isBackend.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/isBackend.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/isFrontend.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/isFrontend.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/omit.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/omit.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/pick.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/pick.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/toArray.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/toArray.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/typedEntries.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/typedEntries.d.ts.map +0 -0
- /package/dist/{src → commonjs}/utils/typedInclude.d.ts +0 -0
- /package/dist/{src → commonjs}/utils/typedInclude.d.ts.map +0 -0
- /package/dist/{src → commonjs}/vendor/fetch-event-source/parse.d.ts +0 -0
- /package/dist/{src → commonjs}/vendor/fetch-event-source/parse.spec.d.ts +0 -0
- /package/dist/{src → commonjs}/vendor/fetch-event-source/parse.spec.d.ts.map +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ObjectDetectionInput, ObjectDetectionOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
6
|
-
import { preparePayload, type LegacyImageInput } from "./utils";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
|
+
import { preparePayload, type LegacyImageInput } from "./utils.js";
|
|
7
7
|
|
|
8
8
|
export type ObjectDetectionArgs = BaseArgs & (ObjectDetectionInput | LegacyImageInput);
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TextToImageInput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import { makeRequestOptions } from "../../lib/makeRequestOptions";
|
|
5
|
-
import type { BaseArgs, Options } from "../../types";
|
|
6
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import { makeRequestOptions } from "../../lib/makeRequestOptions.js";
|
|
5
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
6
|
+
import { innerRequest } from "../../utils/request.js";
|
|
7
7
|
|
|
8
8
|
export type TextToImageArgs = BaseArgs & TextToImageInput;
|
|
9
9
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { TextToVideoInput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import { makeRequestOptions } from "../../lib/makeRequestOptions";
|
|
5
|
-
import type { FalAiQueueOutput } from "../../providers/fal-ai";
|
|
6
|
-
import type { NovitaOutput } from "../../providers/novita";
|
|
7
|
-
import type { ReplicateOutput } from "../../providers/replicate";
|
|
8
|
-
import type { BaseArgs, Options } from "../../types";
|
|
9
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import { makeRequestOptions } from "../../lib/makeRequestOptions.js";
|
|
5
|
+
import type { FalAiQueueOutput } from "../../providers/fal-ai.js";
|
|
6
|
+
import type { NovitaOutput } from "../../providers/novita.js";
|
|
7
|
+
import type { ReplicateOutput } from "../../providers/replicate.js";
|
|
8
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
9
|
+
import { innerRequest } from "../../utils/request.js";
|
|
10
10
|
|
|
11
11
|
export type TextToVideoArgs = BaseArgs & TextToVideoInput;
|
|
12
12
|
|
package/src/tasks/cv/utils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ZeroShotImageClassificationInput, ZeroShotImageClassificationOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options, RequestArgs } from "../../types";
|
|
5
|
-
import { base64FromBytes } from "../../utils/base64FromBytes";
|
|
6
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options, RequestArgs } from "../../types.js";
|
|
5
|
+
import { base64FromBytes } from "../../utils/base64FromBytes.js";
|
|
6
|
+
import { innerRequest } from "../../utils/request.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @deprecated
|
package/src/tasks/index.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
// Custom tasks with arbitrary inputs and outputs
|
|
2
|
-
export * from "./custom/request";
|
|
3
|
-
export * from "./custom/streamingRequest";
|
|
2
|
+
export * from "./custom/request.js";
|
|
3
|
+
export * from "./custom/streamingRequest.js";
|
|
4
4
|
|
|
5
5
|
// Audio tasks
|
|
6
|
-
export * from "./audio/audioClassification";
|
|
7
|
-
export * from "./audio/audioToAudio";
|
|
8
|
-
export * from "./audio/automaticSpeechRecognition";
|
|
9
|
-
export * from "./audio/textToSpeech";
|
|
6
|
+
export * from "./audio/audioClassification.js";
|
|
7
|
+
export * from "./audio/audioToAudio.js";
|
|
8
|
+
export * from "./audio/automaticSpeechRecognition.js";
|
|
9
|
+
export * from "./audio/textToSpeech.js";
|
|
10
10
|
|
|
11
11
|
// Computer Vision tasks
|
|
12
|
-
export * from "./cv/imageClassification";
|
|
13
|
-
export * from "./cv/imageSegmentation";
|
|
14
|
-
export * from "./cv/imageToImage";
|
|
15
|
-
export * from "./cv/imageToText";
|
|
16
|
-
export * from "./cv/objectDetection";
|
|
17
|
-
export * from "./cv/textToImage";
|
|
18
|
-
export * from "./cv/textToVideo";
|
|
19
|
-
export * from "./cv/zeroShotImageClassification";
|
|
12
|
+
export * from "./cv/imageClassification.js";
|
|
13
|
+
export * from "./cv/imageSegmentation.js";
|
|
14
|
+
export * from "./cv/imageToImage.js";
|
|
15
|
+
export * from "./cv/imageToText.js";
|
|
16
|
+
export * from "./cv/objectDetection.js";
|
|
17
|
+
export * from "./cv/textToImage.js";
|
|
18
|
+
export * from "./cv/textToVideo.js";
|
|
19
|
+
export * from "./cv/zeroShotImageClassification.js";
|
|
20
20
|
|
|
21
21
|
// Natural Language Processing tasks
|
|
22
|
-
export * from "./nlp/chatCompletion";
|
|
23
|
-
export * from "./nlp/chatCompletionStream";
|
|
24
|
-
export * from "./nlp/featureExtraction";
|
|
25
|
-
export * from "./nlp/fillMask";
|
|
26
|
-
export * from "./nlp/questionAnswering";
|
|
27
|
-
export * from "./nlp/sentenceSimilarity";
|
|
28
|
-
export * from "./nlp/summarization";
|
|
29
|
-
export * from "./nlp/tableQuestionAnswering";
|
|
30
|
-
export * from "./nlp/textClassification";
|
|
31
|
-
export * from "./nlp/textGeneration";
|
|
32
|
-
export * from "./nlp/textGenerationStream";
|
|
33
|
-
export * from "./nlp/tokenClassification";
|
|
34
|
-
export * from "./nlp/translation";
|
|
35
|
-
export * from "./nlp/zeroShotClassification";
|
|
22
|
+
export * from "./nlp/chatCompletion.js";
|
|
23
|
+
export * from "./nlp/chatCompletionStream.js";
|
|
24
|
+
export * from "./nlp/featureExtraction.js";
|
|
25
|
+
export * from "./nlp/fillMask.js";
|
|
26
|
+
export * from "./nlp/questionAnswering.js";
|
|
27
|
+
export * from "./nlp/sentenceSimilarity.js";
|
|
28
|
+
export * from "./nlp/summarization.js";
|
|
29
|
+
export * from "./nlp/tableQuestionAnswering.js";
|
|
30
|
+
export * from "./nlp/textClassification.js";
|
|
31
|
+
export * from "./nlp/textGeneration.js";
|
|
32
|
+
export * from "./nlp/textGenerationStream.js";
|
|
33
|
+
export * from "./nlp/tokenClassification.js";
|
|
34
|
+
export * from "./nlp/translation.js";
|
|
35
|
+
export * from "./nlp/zeroShotClassification.js";
|
|
36
36
|
|
|
37
37
|
// Multimodal tasks
|
|
38
|
-
export * from "./multimodal/documentQuestionAnswering";
|
|
39
|
-
export * from "./multimodal/visualQuestionAnswering";
|
|
38
|
+
export * from "./multimodal/documentQuestionAnswering.js";
|
|
39
|
+
export * from "./multimodal/visualQuestionAnswering.js";
|
|
40
40
|
|
|
41
41
|
// Tabular tasks
|
|
42
|
-
export * from "./tabular/tabularClassification";
|
|
43
|
-
export * from "./tabular/tabularRegression";
|
|
42
|
+
export * from "./tabular/tabularClassification.js";
|
|
43
|
+
export * from "./tabular/tabularRegression.js";
|
|
@@ -3,11 +3,11 @@ import type {
|
|
|
3
3
|
DocumentQuestionAnsweringInputData,
|
|
4
4
|
DocumentQuestionAnsweringOutput,
|
|
5
5
|
} from "@huggingface/tasks";
|
|
6
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
7
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
8
|
-
import type { BaseArgs, Options, RequestArgs } from "../../types";
|
|
9
|
-
import { base64FromBytes } from "../../utils/base64FromBytes";
|
|
10
|
-
import { innerRequest } from "../../utils/request";
|
|
6
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
7
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
8
|
+
import type { BaseArgs, Options, RequestArgs } from "../../types.js";
|
|
9
|
+
import { base64FromBytes } from "../../utils/base64FromBytes.js";
|
|
10
|
+
import { innerRequest } from "../../utils/request.js";
|
|
11
11
|
|
|
12
12
|
/// Override the type to properly set inputs.image as Blob
|
|
13
13
|
export type DocumentQuestionAnsweringArgs = BaseArgs &
|
|
@@ -3,11 +3,11 @@ import type {
|
|
|
3
3
|
VisualQuestionAnsweringInputData,
|
|
4
4
|
VisualQuestionAnsweringOutput,
|
|
5
5
|
} from "@huggingface/tasks";
|
|
6
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
7
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
8
|
-
import type { BaseArgs, Options, RequestArgs } from "../../types";
|
|
9
|
-
import { base64FromBytes } from "../../utils/base64FromBytes";
|
|
10
|
-
import { innerRequest } from "../../utils/request";
|
|
6
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
7
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
8
|
+
import type { BaseArgs, Options, RequestArgs } from "../../types.js";
|
|
9
|
+
import { base64FromBytes } from "../../utils/base64FromBytes.js";
|
|
10
|
+
import { innerRequest } from "../../utils/request.js";
|
|
11
11
|
|
|
12
12
|
/// Override the type to properly set inputs.image as Blob
|
|
13
13
|
export type VisualQuestionAnsweringArgs = BaseArgs &
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ChatCompletionInput, ChatCompletionOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Use the chat completion endpoint to generate a response to a prompt, using OpenAI message completion API no stream
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ChatCompletionInput, ChatCompletionStreamOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerStreamingRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerStreamingRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Use to continue text from a prompt. Same as `textGeneration` but returns generator that can be read one token at a time
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FeatureExtractionInput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
interface FeatureExtractionOAICompatInput {
|
|
8
8
|
encoding_format?: "float" | "base64";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FillMaskInput, FillMaskOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type FillMaskArgs = BaseArgs & FillMaskInput;
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { QuestionAnsweringInput, QuestionAnsweringOutput } from "@huggingface/tasks";
|
|
2
2
|
|
|
3
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
4
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
5
|
-
import type { BaseArgs, Options } from "../../types";
|
|
6
|
-
import { innerRequest } from "../../utils/request";
|
|
3
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
4
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
5
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
6
|
+
import { innerRequest } from "../../utils/request.js";
|
|
7
7
|
|
|
8
8
|
export type QuestionAnsweringArgs = BaseArgs & QuestionAnsweringInput;
|
|
9
9
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SentenceSimilarityInput, SentenceSimilarityOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type SentenceSimilarityArgs = BaseArgs & SentenceSimilarityInput;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SummarizationInput, SummarizationOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type SummarizationArgs = BaseArgs & SummarizationInput;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TableQuestionAnsweringInput, TableQuestionAnsweringOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type TableQuestionAnsweringArgs = BaseArgs & TableQuestionAnsweringInput;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TextClassificationInput, TextClassificationOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type TextClassificationArgs = BaseArgs & TextClassificationInput;
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TextGenerationInput, TextGenerationOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { HyperbolicTextCompletionOutput } from "../../providers/hyperbolic";
|
|
5
|
-
import type { BaseArgs, Options } from "../../types";
|
|
6
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { HyperbolicTextCompletionOutput } from "../../providers/hyperbolic.js";
|
|
5
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
6
|
+
import { innerRequest } from "../../utils/request.js";
|
|
7
7
|
|
|
8
8
|
export type { TextGenerationInput, TextGenerationOutput };
|
|
9
9
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TextGenerationInput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerStreamingRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerStreamingRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export interface TextGenerationStreamToken {
|
|
8
8
|
/** Token ID from the model tokenizer */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TokenClassificationInput, TokenClassificationOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type TokenClassificationArgs = BaseArgs & TokenClassificationInput;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TranslationInput, TranslationOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type TranslationArgs = BaseArgs & TranslationInput;
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ZeroShotClassificationInput, ZeroShotClassificationOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import type { BaseArgs, Options } from "../../types";
|
|
5
|
-
import { innerRequest } from "../../utils/request";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
5
|
+
import { innerRequest } from "../../utils/request.js";
|
|
6
6
|
|
|
7
7
|
export type ZeroShotClassificationArgs = BaseArgs & ZeroShotClassificationInput;
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
2
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
3
|
-
import type { BaseArgs, Options } from "../../types";
|
|
4
|
-
import { innerRequest } from "../../utils/request";
|
|
1
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
2
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
3
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
4
|
+
import { innerRequest } from "../../utils/request.js";
|
|
5
5
|
|
|
6
6
|
export type TabularClassificationArgs = BaseArgs & {
|
|
7
7
|
inputs: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
2
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
3
|
-
import type { BaseArgs, Options } from "../../types";
|
|
4
|
-
import { innerRequest } from "../../utils/request";
|
|
1
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
2
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
3
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
4
|
+
import { innerRequest } from "../../utils/request.js";
|
|
5
5
|
|
|
6
6
|
export type TabularRegressionArgs = BaseArgs & {
|
|
7
7
|
inputs: {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChatCompletionInput, PipelineType } from "@huggingface/tasks";
|
|
2
|
-
import type { InferenceProviderModelMapping } from "./lib/getInferenceProviderMapping";
|
|
2
|
+
import type { InferenceProviderModelMapping } from "./lib/getInferenceProviderMapping.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* HF model id, like "meta-llama/Llama-3.3-70B-Instruct"
|
package/src/utils/isFrontend.ts
CHANGED
package/src/utils/omit.ts
CHANGED
package/src/utils/request.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { getProviderHelper } from "../lib/getProviderHelper";
|
|
2
|
-
import { makeRequestOptions } from "../lib/makeRequestOptions";
|
|
3
|
-
import type { InferenceTask, Options, RequestArgs } from "../types";
|
|
4
|
-
import type { EventSourceMessage } from "../vendor/fetch-event-source/parse";
|
|
5
|
-
import { getLines, getMessages } from "../vendor/fetch-event-source/parse";
|
|
1
|
+
import type { getProviderHelper } from "../lib/getProviderHelper.js";
|
|
2
|
+
import { makeRequestOptions } from "../lib/makeRequestOptions.js";
|
|
3
|
+
import type { InferenceTask, Options, RequestArgs } from "../types.js";
|
|
4
|
+
import type { EventSourceMessage } from "../vendor/fetch-event-source/parse.js";
|
|
5
|
+
import { getLines, getMessages } from "../vendor/fetch-event-source/parse.js";
|
|
6
6
|
|
|
7
7
|
export interface ResponseWrapper<T> {
|
|
8
8
|
data: T;
|
|
@@ -52,7 +52,7 @@ export interface EventSourceMessage {
|
|
|
52
52
|
* @param onChunk A function that will be called on each new byte chunk in the stream.
|
|
53
53
|
* @returns {Promise<void>} A promise that will be resolved when the stream closes.
|
|
54
54
|
*/
|
|
55
|
-
export async function getBytes(stream: ReadableStream<Uint8Array>, onChunk: (arr: Uint8Array) => void) {
|
|
55
|
+
export async function getBytes(stream: ReadableStream<Uint8Array>, onChunk: (arr: Uint8Array) => void): Promise<void> {
|
|
56
56
|
const reader = stream.getReader();
|
|
57
57
|
let result: ReadableStreamReadResult<Uint8Array>;
|
|
58
58
|
while (!(result = await reader.read()).done) {
|
|
@@ -73,7 +73,7 @@ const enum ControlChars {
|
|
|
73
73
|
* @param onLine A function that will be called on each new EventSource line.
|
|
74
74
|
* @returns A function that should be called for each incoming byte chunk.
|
|
75
75
|
*/
|
|
76
|
-
export function getLines(onLine: (line: Uint8Array, fieldLength: number) => void) {
|
|
76
|
+
export function getLines(onLine: (line: Uint8Array, fieldLength: number) => void): (arr: Uint8Array) => void {
|
|
77
77
|
let buffer: Uint8Array | undefined;
|
|
78
78
|
let position: number; // current read position
|
|
79
79
|
let fieldLength: number; // length of the `field` portion of the line
|
|
@@ -110,9 +110,9 @@ export function getLines(onLine: (line: Uint8Array, fieldLength: number) => void
|
|
|
110
110
|
fieldLength = position - lineStart;
|
|
111
111
|
}
|
|
112
112
|
break;
|
|
113
|
-
// @ts-ignore:7029 \r case below should fallthrough to \n:
|
|
114
113
|
case ControlChars.CarriageReturn:
|
|
115
114
|
discardTrailingNewline = true;
|
|
115
|
+
// eslint-disable-next-line no-fallthrough
|
|
116
116
|
case ControlChars.NewLine:
|
|
117
117
|
lineEnd = position;
|
|
118
118
|
break;
|
|
@@ -153,7 +153,7 @@ export function getMessages(
|
|
|
153
153
|
onId: (id: string) => void,
|
|
154
154
|
onRetry: (retry: number) => void,
|
|
155
155
|
onMessage?: (msg: EventSourceMessage) => void
|
|
156
|
-
) {
|
|
156
|
+
): (line: Uint8Array, fieldLength: number) => void {
|
|
157
157
|
let message = newMessage();
|
|
158
158
|
const decoder = new TextDecoder();
|
|
159
159
|
|
|
@@ -184,12 +184,13 @@ export function getMessages(
|
|
|
184
184
|
case 'id':
|
|
185
185
|
onId(message.id = value);
|
|
186
186
|
break;
|
|
187
|
-
case 'retry':
|
|
187
|
+
case 'retry': {
|
|
188
188
|
const retry = parseInt(value, 10);
|
|
189
189
|
if (!isNaN(retry)) { // per spec, ignore non-integers
|
|
190
190
|
onRetry(message.retry = retry);
|
|
191
191
|
}
|
|
192
192
|
break;
|
|
193
|
+
}
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
}
|