@huggingface/inference 3.13.0 → 3.13.2-tshy
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 +119 -124
- package/dist/{src → commonjs}/InferenceClient.d.ts +2 -2
- package/dist/commonjs/InferenceClient.d.ts.map +1 -0
- package/dist/commonjs/InferenceClient.js +84 -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/{src → commonjs}/lib/getDefaultTask.d.ts.map +1 -1
- 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 +32 -32
- package/dist/commonjs/lib/getProviderHelper.d.ts.map +1 -0
- 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 +166 -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 +4 -18
- package/dist/commonjs/providers/fal-ai.d.ts.map +1 -0
- 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 +8 -4
- package/dist/commonjs/providers/hf-inference.d.ts.map +1 -0
- 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 +6 -2
- package/dist/commonjs/providers/providerHelper.d.ts.map +1 -0
- 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/{src → commonjs}/snippets/templates.exported.d.ts.map +1 -1
- 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 +45 -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 +159 -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 +25 -11
- package/src/InferenceClient.ts +5 -4
- package/src/index.ts +4 -4
- package/src/lib/getDefaultTask.ts +4 -3
- package/src/lib/getInferenceProviderMapping.ts +5 -5
- package/src/lib/getProviderHelper.ts +58 -54
- package/src/lib/makeRequestOptions.ts +10 -8
- 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 +32 -7
- 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 +37 -8
- 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 +9 -5
- 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 +20 -11
- package/src/snippets/templates.exported.ts +3 -1
- package/src/tasks/audio/audioClassification.ts +6 -6
- package/src/tasks/audio/audioToAudio.ts +6 -6
- package/src/tasks/audio/automaticSpeechRecognition.ts +7 -37
- 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 +6 -21
- 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 -2856
- package/dist/index.js +0 -2800
- package/dist/src/InferenceClient.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/lib/getProviderHelper.d.ts.map +0 -1
- package/dist/src/providers/consts.d.ts.map +0 -1
- package/dist/src/providers/fal-ai.d.ts.map +0 -1
- package/dist/src/providers/fireworks-ai.d.ts.map +0 -1
- package/dist/src/providers/hf-inference.d.ts.map +0 -1
- package/dist/src/providers/providerHelper.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/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}/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,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-ignore this works or not depending on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783
|
|
3
|
+
import pkg from "../../package.json" with { type: "json" };
|
|
4
|
+
import { HF_HEADER_X_BILL_TO, HF_HUB_URL } from "../config.js";
|
|
5
|
+
import type { InferenceTask, Options, RequestArgs } from "../types.js";
|
|
6
|
+
import type { InferenceProviderModelMapping } from "./getInferenceProviderMapping.js";
|
|
7
|
+
import { getInferenceProviderMapping } from "./getInferenceProviderMapping.js";
|
|
8
|
+
import type { getProviderHelper } from "./getProviderHelper.js";
|
|
9
|
+
import { isUrl } from "./isUrl.js";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Lazy-loaded from huggingface.co/api/tasks when needed
|
|
@@ -158,7 +160,7 @@ export function makeRequestOptionsFromResolvedModel(
|
|
|
158
160
|
|
|
159
161
|
// Add user-agent to headers
|
|
160
162
|
// e.g. @huggingface/inference/3.1.3
|
|
161
|
-
const ownUserAgent = `${
|
|
163
|
+
const ownUserAgent = `${pkg.name}/${pkg.version}`;
|
|
162
164
|
const userAgent = [ownUserAgent, typeof navigator !== "undefined" ? navigator.userAgent : undefined]
|
|
163
165
|
.filter((x) => x !== undefined)
|
|
164
166
|
.join(" ");
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
18
|
-
import type { BodyParams, HeaderParams, UrlParams } from "../types";
|
|
19
|
-
import { delay } from "../utils/delay";
|
|
20
|
-
import { omit } from "../utils/omit";
|
|
21
|
-
import { TaskProviderHelper, type TextToImageTaskHelper } from "./providerHelper";
|
|
17
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
18
|
+
import type { BodyParams, HeaderParams, UrlParams } from "../types.js";
|
|
19
|
+
import { delay } from "../utils/delay.js";
|
|
20
|
+
import { omit } from "../utils/omit.js";
|
|
21
|
+
import { TaskProviderHelper, type TextToImageTaskHelper } from "./providerHelper.js";
|
|
22
22
|
|
|
23
23
|
const BLACK_FOREST_LABS_AI_API_BASE_URL = "https://api.us1.bfl.ai";
|
|
24
24
|
interface BlackForestLabsResponse {
|
package/src/providers/cohere.ts
CHANGED
package/src/providers/consts.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { InferenceProviderModelMapping } from "../lib/getInferenceProviderMapping";
|
|
2
|
-
import type { InferenceProvider } from "../types";
|
|
3
|
-
import { type ModelId } from "../types";
|
|
1
|
+
import type { InferenceProviderModelMapping } from "../lib/getInferenceProviderMapping.js";
|
|
2
|
+
import type { InferenceProvider } from "../types.js";
|
|
3
|
+
import { type ModelId } from "../types.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* If you want to try to run inference for a new model locally before it's registered on huggingface.co
|
package/src/providers/fal-ai.ts
CHANGED
|
@@ -14,19 +14,22 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
|
+
import { base64FromBytes } from "../utils/base64FromBytes.js";
|
|
18
|
+
|
|
17
19
|
import type { AutomaticSpeechRecognitionOutput } from "@huggingface/tasks";
|
|
18
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
19
|
-
import { isUrl } from "../lib/isUrl";
|
|
20
|
-
import type { BodyParams, HeaderParams, ModelId, UrlParams } from "../types";
|
|
21
|
-
import { delay } from "../utils/delay";
|
|
22
|
-
import { omit } from "../utils/omit";
|
|
20
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
21
|
+
import { isUrl } from "../lib/isUrl.js";
|
|
22
|
+
import type { BodyParams, HeaderParams, ModelId, RequestArgs, UrlParams } from "../types.js";
|
|
23
|
+
import { delay } from "../utils/delay.js";
|
|
24
|
+
import { omit } from "../utils/omit.js";
|
|
23
25
|
import {
|
|
24
26
|
type AutomaticSpeechRecognitionTaskHelper,
|
|
25
27
|
TaskProviderHelper,
|
|
26
28
|
type TextToImageTaskHelper,
|
|
27
29
|
type TextToVideoTaskHelper,
|
|
28
|
-
} from "./providerHelper";
|
|
29
|
-
import { HF_HUB_URL } from "../config";
|
|
30
|
+
} from "./providerHelper.js";
|
|
31
|
+
import { HF_HUB_URL } from "../config.js";
|
|
32
|
+
import type { AutomaticSpeechRecognitionArgs } from "../tasks/audio/automaticSpeechRecognition.js";
|
|
30
33
|
|
|
31
34
|
export interface FalAiQueueOutput {
|
|
32
35
|
request_id: string;
|
|
@@ -224,6 +227,28 @@ export class FalAIAutomaticSpeechRecognitionTask extends FalAITask implements Au
|
|
|
224
227
|
}
|
|
225
228
|
return { text: res.text };
|
|
226
229
|
}
|
|
230
|
+
|
|
231
|
+
async preparePayloadAsync(args: AutomaticSpeechRecognitionArgs): Promise<RequestArgs> {
|
|
232
|
+
const blob = "data" in args && args.data instanceof Blob ? args.data : "inputs" in args ? args.inputs : undefined;
|
|
233
|
+
const contentType = blob?.type;
|
|
234
|
+
if (!contentType) {
|
|
235
|
+
throw new Error(
|
|
236
|
+
`Unable to determine the input's content-type. Make sure your are passing a Blob when using provider fal-ai.`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
if (!FAL_AI_SUPPORTED_BLOB_TYPES.includes(contentType)) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
`Provider fal-ai does not support blob type ${contentType} - supported content types are: ${FAL_AI_SUPPORTED_BLOB_TYPES.join(
|
|
242
|
+
", "
|
|
243
|
+
)}`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
const base64audio = base64FromBytes(new Uint8Array(await blob.arrayBuffer()));
|
|
247
|
+
return {
|
|
248
|
+
...("data" in args ? omit(args, "data") : omit(args, "inputs")),
|
|
249
|
+
audio_url: `data:${contentType};base64,${base64audio}`,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
227
252
|
}
|
|
228
253
|
|
|
229
254
|
export class FalAITextToSpeechTask extends FalAITask {
|
|
@@ -4,9 +4,9 @@ import type {
|
|
|
4
4
|
TextGenerationOutput,
|
|
5
5
|
TextGenerationOutputFinishReason,
|
|
6
6
|
} from "@huggingface/tasks";
|
|
7
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
8
|
-
import type { BodyParams } from "../types";
|
|
9
|
-
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper";
|
|
7
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
8
|
+
import type { BodyParams } from "../types.js";
|
|
9
|
+
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper.js";
|
|
10
10
|
|
|
11
11
|
interface FeatherlessAITextCompletionOutput extends Omit<ChatCompletionOutput, "choices"> {
|
|
12
12
|
choices: Array<{
|
package/src/providers/groq.ts
CHANGED
|
@@ -33,11 +33,11 @@ import type {
|
|
|
33
33
|
ZeroShotClassificationOutput,
|
|
34
34
|
ZeroShotImageClassificationOutput,
|
|
35
35
|
} from "@huggingface/tasks";
|
|
36
|
-
import { HF_ROUTER_URL } from "../config";
|
|
37
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
38
|
-
import type { TabularClassificationOutput } from "../tasks/tabular/tabularClassification";
|
|
39
|
-
import type { BodyParams, UrlParams } from "../types";
|
|
40
|
-
import { toArray } from "../utils/toArray";
|
|
36
|
+
import { HF_ROUTER_URL } from "../config.js";
|
|
37
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
38
|
+
import type { TabularClassificationOutput } from "../tasks/tabular/tabularClassification.js";
|
|
39
|
+
import type { BodyParams, RequestArgs, UrlParams } from "../types.js";
|
|
40
|
+
import { toArray } from "../utils/toArray.js";
|
|
41
41
|
import type {
|
|
42
42
|
AudioClassificationTaskHelper,
|
|
43
43
|
AudioToAudioTaskHelper,
|
|
@@ -67,10 +67,13 @@ import type {
|
|
|
67
67
|
VisualQuestionAnsweringTaskHelper,
|
|
68
68
|
ZeroShotClassificationTaskHelper,
|
|
69
69
|
ZeroShotImageClassificationTaskHelper,
|
|
70
|
-
} from "./providerHelper";
|
|
71
|
-
|
|
72
|
-
import { TaskProviderHelper } from "./providerHelper";
|
|
70
|
+
} from "./providerHelper.js";
|
|
73
71
|
|
|
72
|
+
import { TaskProviderHelper } from "./providerHelper.js";
|
|
73
|
+
import { base64FromBytes } from "../utils/base64FromBytes.js";
|
|
74
|
+
import type { ImageToImageArgs } from "../tasks/cv/imageToImage.js";
|
|
75
|
+
import type { AutomaticSpeechRecognitionArgs } from "../tasks/audio/automaticSpeechRecognition.js";
|
|
76
|
+
import { omit } from "../utils/omit.js";
|
|
74
77
|
interface Base64ImageGeneration {
|
|
75
78
|
data: Array<{
|
|
76
79
|
b64_json: string;
|
|
@@ -221,6 +224,15 @@ export class HFInferenceAutomaticSpeechRecognitionTask
|
|
|
221
224
|
override async getResponse(response: AutomaticSpeechRecognitionOutput): Promise<AutomaticSpeechRecognitionOutput> {
|
|
222
225
|
return response;
|
|
223
226
|
}
|
|
227
|
+
|
|
228
|
+
async preparePayloadAsync(args: AutomaticSpeechRecognitionArgs): Promise<RequestArgs> {
|
|
229
|
+
return "data" in args
|
|
230
|
+
? args
|
|
231
|
+
: {
|
|
232
|
+
...omit(args, "inputs"),
|
|
233
|
+
data: args.inputs,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
224
236
|
}
|
|
225
237
|
|
|
226
238
|
export class HFInferenceAudioToAudioTask extends HFInferenceTask implements AudioToAudioTaskHelper {
|
|
@@ -326,6 +338,23 @@ export class HFInferenceImageToTextTask extends HFInferenceTask implements Image
|
|
|
326
338
|
}
|
|
327
339
|
|
|
328
340
|
export class HFInferenceImageToImageTask extends HFInferenceTask implements ImageToImageTaskHelper {
|
|
341
|
+
async preparePayloadAsync(args: ImageToImageArgs): Promise<RequestArgs> {
|
|
342
|
+
if (!args.parameters) {
|
|
343
|
+
return {
|
|
344
|
+
...args,
|
|
345
|
+
model: args.model,
|
|
346
|
+
data: args.inputs,
|
|
347
|
+
};
|
|
348
|
+
} else {
|
|
349
|
+
return {
|
|
350
|
+
...args,
|
|
351
|
+
inputs: base64FromBytes(
|
|
352
|
+
new Uint8Array(args.inputs instanceof ArrayBuffer ? args.inputs : await (args.inputs as Blob).arrayBuffer())
|
|
353
|
+
),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
329
358
|
override async getResponse(response: Blob): Promise<Blob> {
|
|
330
359
|
if (response instanceof Blob) {
|
|
331
360
|
return response;
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
import type { ChatCompletionOutput, TextGenerationOutput } from "@huggingface/tasks";
|
|
18
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
19
|
-
import type { BodyParams, UrlParams } from "../types";
|
|
20
|
-
import { omit } from "../utils/omit";
|
|
18
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
19
|
+
import type { BodyParams, UrlParams } from "../types.js";
|
|
20
|
+
import { omit } from "../utils/omit.js";
|
|
21
21
|
import {
|
|
22
22
|
BaseConversationalTask,
|
|
23
23
|
BaseTextGenerationTask,
|
|
24
24
|
TaskProviderHelper,
|
|
25
25
|
type TextToImageTaskHelper,
|
|
26
|
-
} from "./providerHelper";
|
|
26
|
+
} from "./providerHelper.js";
|
|
27
27
|
|
|
28
28
|
const HYPERBOLIC_API_BASE_URL = "https://api.hyperbolic.xyz";
|
|
29
29
|
|
package/src/providers/nebius.ts
CHANGED
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
import type { FeatureExtractionOutput } from "@huggingface/tasks";
|
|
18
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
19
|
-
import type { BodyParams } from "../types";
|
|
20
|
-
import { omit } from "../utils/omit";
|
|
18
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
19
|
+
import type { BodyParams } from "../types.js";
|
|
20
|
+
import { omit } from "../utils/omit.js";
|
|
21
21
|
import {
|
|
22
22
|
BaseConversationalTask,
|
|
23
23
|
BaseTextGenerationTask,
|
|
24
24
|
TaskProviderHelper,
|
|
25
25
|
type FeatureExtractionTaskHelper,
|
|
26
26
|
type TextToImageTaskHelper,
|
|
27
|
-
} from "./providerHelper";
|
|
27
|
+
} from "./providerHelper.js";
|
|
28
28
|
|
|
29
29
|
const NEBIUS_API_BASE_URL = "https://api.studio.nebius.ai";
|
|
30
30
|
|
package/src/providers/novita.ts
CHANGED
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
18
|
-
import { isUrl } from "../lib/isUrl";
|
|
19
|
-
import type { BodyParams, UrlParams } from "../types";
|
|
20
|
-
import { omit } from "../utils/omit";
|
|
17
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
18
|
+
import { isUrl } from "../lib/isUrl.js";
|
|
19
|
+
import type { BodyParams, UrlParams } from "../types.js";
|
|
20
|
+
import { omit } from "../utils/omit.js";
|
|
21
21
|
import {
|
|
22
22
|
BaseConversationalTask,
|
|
23
23
|
BaseTextGenerationTask,
|
|
24
24
|
TaskProviderHelper,
|
|
25
25
|
type TextToVideoTaskHelper,
|
|
26
|
-
} from "./providerHelper";
|
|
26
|
+
} from "./providerHelper.js";
|
|
27
27
|
|
|
28
28
|
const NOVITA_API_BASE_URL = "https://api.novita.ai";
|
|
29
29
|
export interface NovitaOutput {
|
package/src/providers/nscale.ts
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
import type { TextToImageInput } from "@huggingface/tasks";
|
|
18
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
19
|
-
import type { BodyParams } from "../types";
|
|
20
|
-
import { omit } from "../utils/omit";
|
|
21
|
-
import { BaseConversationalTask, TaskProviderHelper, type TextToImageTaskHelper } from "./providerHelper";
|
|
18
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
19
|
+
import type { BodyParams } from "../types.js";
|
|
20
|
+
import { omit } from "../utils/omit.js";
|
|
21
|
+
import { BaseConversationalTask, TaskProviderHelper, type TextToImageTaskHelper } from "./providerHelper.js";
|
|
22
22
|
|
|
23
23
|
const NSCALE_API_BASE_URL = "https://inference.api.nscale.com";
|
|
24
24
|
|
package/src/providers/openai.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Special case: provider configuration for a private models provider (OpenAI in this case).
|
|
3
3
|
*/
|
|
4
|
-
import { BaseConversationalTask } from "./providerHelper";
|
|
4
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
5
5
|
|
|
6
6
|
const OPENAI_API_BASE_URL = "https://api.openai.com";
|
|
7
7
|
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper";
|
|
18
|
+
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper.js";
|
|
19
19
|
import type { ChatCompletionOutput, TextGenerationOutput, TextGenerationOutputFinishReason } from "@huggingface/tasks";
|
|
20
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
21
|
-
import type { BodyParams } from "../types";
|
|
22
|
-
import { omit } from "../utils/omit";
|
|
20
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
21
|
+
import type { BodyParams } from "../types.js";
|
|
22
|
+
import { omit } from "../utils/omit.js";
|
|
23
23
|
import type { TextGenerationInput } from "@huggingface/tasks";
|
|
24
24
|
|
|
25
25
|
const OVHCLOUD_API_BASE_URL = "https://oai.endpoints.kepler.ai.cloud.ovh.net";
|
|
@@ -45,11 +45,13 @@ import type {
|
|
|
45
45
|
ZeroShotImageClassificationInput,
|
|
46
46
|
ZeroShotImageClassificationOutput,
|
|
47
47
|
} from "@huggingface/tasks";
|
|
48
|
-
import { HF_ROUTER_URL } from "../config";
|
|
49
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
50
|
-
import type { AudioToAudioOutput } from "../tasks/audio/audioToAudio";
|
|
51
|
-
import type { BaseArgs, BodyParams, HeaderParams, InferenceProvider, UrlParams } from "../types";
|
|
52
|
-
import { toArray } from "../utils/toArray";
|
|
48
|
+
import { HF_ROUTER_URL } from "../config.js";
|
|
49
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
50
|
+
import type { AudioToAudioOutput } from "../tasks/audio/audioToAudio.js";
|
|
51
|
+
import type { BaseArgs, BodyParams, HeaderParams, InferenceProvider, RequestArgs, UrlParams } from "../types.js";
|
|
52
|
+
import { toArray } from "../utils/toArray.js";
|
|
53
|
+
import type { ImageToImageArgs } from "../tasks/cv/imageToImage.js";
|
|
54
|
+
import type { AutomaticSpeechRecognitionArgs } from "../tasks/audio/automaticSpeechRecognition.js";
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Base class for task-specific provider helpers
|
|
@@ -142,6 +144,7 @@ export interface TextToVideoTaskHelper {
|
|
|
142
144
|
export interface ImageToImageTaskHelper {
|
|
143
145
|
getResponse(response: unknown, url?: string, headers?: HeadersInit): Promise<Blob>;
|
|
144
146
|
preparePayload(params: BodyParams<ImageToImageInput & BaseArgs>): Record<string, unknown>;
|
|
147
|
+
preparePayloadAsync(args: ImageToImageArgs): Promise<RequestArgs>;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
export interface ImageSegmentationTaskHelper {
|
|
@@ -245,6 +248,7 @@ export interface AudioToAudioTaskHelper {
|
|
|
245
248
|
export interface AutomaticSpeechRecognitionTaskHelper {
|
|
246
249
|
getResponse(response: unknown, url?: string, headers?: HeadersInit): Promise<AutomaticSpeechRecognitionOutput>;
|
|
247
250
|
preparePayload(params: BodyParams<AutomaticSpeechRecognitionInput & BaseArgs>): Record<string, unknown> | BodyInit;
|
|
251
|
+
preparePayloadAsync(args: AutomaticSpeechRecognitionArgs): Promise<RequestArgs>;
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
export interface AudioClassificationTaskHelper {
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
18
|
-
import { isUrl } from "../lib/isUrl";
|
|
19
|
-
import type { BodyParams, HeaderParams, UrlParams } from "../types";
|
|
20
|
-
import { omit } from "../utils/omit";
|
|
21
|
-
import { TaskProviderHelper, type TextToImageTaskHelper, type TextToVideoTaskHelper } from "./providerHelper";
|
|
17
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
18
|
+
import { isUrl } from "../lib/isUrl.js";
|
|
19
|
+
import type { BodyParams, HeaderParams, UrlParams } from "../types.js";
|
|
20
|
+
import { omit } from "../utils/omit.js";
|
|
21
|
+
import { TaskProviderHelper, type TextToImageTaskHelper, type TextToVideoTaskHelper } from "./providerHelper.js";
|
|
22
22
|
export interface ReplicateOutput {
|
|
23
23
|
output?: string | string[];
|
|
24
24
|
}
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
17
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
18
18
|
|
|
19
19
|
import type { FeatureExtractionOutput } from "@huggingface/tasks";
|
|
20
|
-
import type { BodyParams } from "../types";
|
|
21
|
-
import type { FeatureExtractionTaskHelper } from "./providerHelper";
|
|
22
|
-
import { BaseConversationalTask, TaskProviderHelper } from "./providerHelper";
|
|
20
|
+
import type { BodyParams } from "../types.js";
|
|
21
|
+
import type { FeatureExtractionTaskHelper } from "./providerHelper.js";
|
|
22
|
+
import { BaseConversationalTask, TaskProviderHelper } from "./providerHelper.js";
|
|
23
23
|
|
|
24
24
|
export class SambanovaConversationalTask extends BaseConversationalTask {
|
|
25
25
|
constructor() {
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
17
|
import type { ChatCompletionOutput, TextGenerationOutput, TextGenerationOutputFinishReason } from "@huggingface/tasks";
|
|
18
|
-
import { InferenceOutputError } from "../lib/InferenceOutputError";
|
|
19
|
-
import type { BodyParams } from "../types";
|
|
20
|
-
import { omit } from "../utils/omit";
|
|
18
|
+
import { InferenceOutputError } from "../lib/InferenceOutputError.js";
|
|
19
|
+
import type { BodyParams } from "../types.js";
|
|
20
|
+
import { omit } from "../utils/omit.js";
|
|
21
21
|
import {
|
|
22
22
|
BaseConversationalTask,
|
|
23
23
|
BaseTextGenerationTask,
|
|
24
24
|
TaskProviderHelper,
|
|
25
25
|
type TextToImageTaskHelper,
|
|
26
|
-
} from "./providerHelper";
|
|
26
|
+
} from "./providerHelper.js";
|
|
27
27
|
|
|
28
28
|
const TOGETHER_API_BASE_URL = "https://api.together.xyz";
|
|
29
29
|
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
getModelInputSnippet,
|
|
7
7
|
inferenceSnippetLanguages,
|
|
8
8
|
} from "@huggingface/tasks";
|
|
9
|
-
import type { PipelineType, WidgetType } from "@huggingface/tasks
|
|
10
|
-
import type { ChatCompletionInputMessage, GenerationParameters } from "@huggingface/tasks
|
|
11
|
-
import type { InferenceProviderModelMapping } from "../lib/getInferenceProviderMapping";
|
|
12
|
-
import { getProviderHelper } from "../lib/getProviderHelper";
|
|
13
|
-
import { makeRequestOptionsFromResolvedModel } from "../lib/makeRequestOptions";
|
|
14
|
-
import type { InferenceProviderOrPolicy, InferenceTask, RequestArgs } from "../types";
|
|
15
|
-
import { templates } from "./templates.exported";
|
|
9
|
+
import type { PipelineType, WidgetType } from "@huggingface/tasks";
|
|
10
|
+
import type { ChatCompletionInputMessage, GenerationParameters } from "@huggingface/tasks";
|
|
11
|
+
import type { InferenceProviderModelMapping } from "../lib/getInferenceProviderMapping.js";
|
|
12
|
+
import { getProviderHelper } from "../lib/getProviderHelper.js";
|
|
13
|
+
import { makeRequestOptionsFromResolvedModel } from "../lib/makeRequestOptions.js";
|
|
14
|
+
import type { InferenceProviderOrPolicy, InferenceTask, RequestArgs } from "../types.js";
|
|
15
|
+
import { templates } from "./templates.exported.js";
|
|
16
16
|
|
|
17
17
|
export type InferenceSnippetOptions = { streaming?: boolean; billTo?: string } & Record<string, unknown>;
|
|
18
18
|
|
|
@@ -144,8 +144,7 @@ const snippetGenerator = (templateName: string, inputPreparationFn?: InputPrepar
|
|
|
144
144
|
}
|
|
145
145
|
let providerHelper: ReturnType<typeof getProviderHelper>;
|
|
146
146
|
try {
|
|
147
|
-
|
|
148
|
-
providerHelper = getProviderHelper(provider === "auto" ? "hf-inference" : provider, task);
|
|
147
|
+
providerHelper = getProviderHelper(provider, task);
|
|
149
148
|
} catch (e) {
|
|
150
149
|
console.error(`Failed to get provider helper for ${provider} (${task})`, e);
|
|
151
150
|
return [];
|
|
@@ -285,6 +284,16 @@ const prepareConversationalInput = (
|
|
|
285
284
|
};
|
|
286
285
|
};
|
|
287
286
|
|
|
287
|
+
const prepareQuestionAnsweringInput = (model: ModelDataMinimal): object => {
|
|
288
|
+
const data = JSON.parse(getModelInputSnippet(model) as string);
|
|
289
|
+
return { question: data.question, context: data.context };
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const prepareTableQuestionAnsweringInput = (model: ModelDataMinimal): object => {
|
|
293
|
+
const data = JSON.parse(getModelInputSnippet(model) as string);
|
|
294
|
+
return { query: data.query, table: JSON.stringify(data.table) };
|
|
295
|
+
};
|
|
296
|
+
|
|
288
297
|
const snippets: Partial<
|
|
289
298
|
Record<
|
|
290
299
|
PipelineType,
|
|
@@ -309,12 +318,12 @@ const snippets: Partial<
|
|
|
309
318
|
"image-to-image": snippetGenerator("imageToImage", prepareImageToImageInput),
|
|
310
319
|
"image-to-text": snippetGenerator("basicImage"),
|
|
311
320
|
"object-detection": snippetGenerator("basicImage"),
|
|
312
|
-
"question-answering": snippetGenerator("
|
|
321
|
+
"question-answering": snippetGenerator("questionAnswering", prepareQuestionAnsweringInput),
|
|
313
322
|
"sentence-similarity": snippetGenerator("basic"),
|
|
314
323
|
summarization: snippetGenerator("basic"),
|
|
315
324
|
"tabular-classification": snippetGenerator("tabular"),
|
|
316
325
|
"tabular-regression": snippetGenerator("tabular"),
|
|
317
|
-
"table-question-answering": snippetGenerator("
|
|
326
|
+
"table-question-answering": snippetGenerator("tableQuestionAnswering", prepareTableQuestionAnsweringInput),
|
|
318
327
|
"text-classification": snippetGenerator("basic"),
|
|
319
328
|
"text-generation": snippetGenerator("basic"),
|
|
320
329
|
"text-to-audio": snippetGenerator("textToAudio"),
|
|
@@ -30,7 +30,7 @@ export const templates: Record<string, Record<string, Record<string, string>>> =
|
|
|
30
30
|
"textToImage": "{% if provider == \"fal-ai\" %}\nimport fal_client\n\n{% if providerInputs.asObj.loras is defined and providerInputs.asObj.loras != none %}\nresult = fal_client.subscribe(\n \"{{ providerModelId }}\",\n arguments={\n \"prompt\": {{ inputs.asObj.inputs }},\n \"loras\":{{ providerInputs.asObj.loras | tojson }},\n },\n)\n{% else %}\nresult = fal_client.subscribe(\n \"{{ providerModelId }}\",\n arguments={\n \"prompt\": {{ inputs.asObj.inputs }},\n },\n)\n{% endif %} \nprint(result)\n{% endif %} "
|
|
31
31
|
},
|
|
32
32
|
"huggingface_hub": {
|
|
33
|
-
"basic": "result = client.{{ methodName }}(\n
|
|
33
|
+
"basic": "result = client.{{ methodName }}(\n {{ inputs.asObj.inputs }},\n model=\"{{ model.id }}\",\n)",
|
|
34
34
|
"basicAudio": "output = client.{{ methodName }}({{ inputs.asObj.inputs }}, model=\"{{ model.id }}\")",
|
|
35
35
|
"basicImage": "output = client.{{ methodName }}({{ inputs.asObj.inputs }}, model=\"{{ model.id }}\")",
|
|
36
36
|
"conversational": "completion = client.chat.completions.create(\n model=\"{{ model.id }}\",\n{{ inputs.asPythonString }}\n)\n\nprint(completion.choices[0].message) ",
|
|
@@ -38,6 +38,8 @@ export const templates: Record<string, Record<string, Record<string, string>>> =
|
|
|
38
38
|
"documentQuestionAnswering": "output = client.document_question_answering(\n \"{{ inputs.asObj.image }}\",\n question=\"{{ inputs.asObj.question }}\",\n model=\"{{ model.id }}\",\n) ",
|
|
39
39
|
"imageToImage": "# output is a PIL.Image object\nimage = client.image_to_image(\n \"{{ inputs.asObj.inputs }}\",\n prompt=\"{{ inputs.asObj.parameters.prompt }}\",\n model=\"{{ model.id }}\",\n) ",
|
|
40
40
|
"importInferenceClient": "from huggingface_hub import InferenceClient\n\nclient = InferenceClient(\n provider=\"{{ provider }}\",\n api_key=\"{{ accessToken }}\",\n{% if billTo %}\n bill_to=\"{{ billTo }}\",\n{% endif %}\n)",
|
|
41
|
+
"questionAnswering": "answer = client.question_answering(\n question=\"{{ inputs.asObj.question }}\",\n context=\"{{ inputs.asObj.context }}\",\n model=\"{{ model.id }}\",\n) ",
|
|
42
|
+
"tableQuestionAnswering": "answer = client.question_answering(\n query=\"{{ inputs.asObj.query }}\",\n table={{ inputs.asObj.table }},\n model=\"{{ model.id }}\",\n) ",
|
|
41
43
|
"textToImage": "# output is a PIL.Image object\nimage = client.text_to_image(\n {{ inputs.asObj.inputs }},\n model=\"{{ model.id }}\",\n) ",
|
|
42
44
|
"textToSpeech": "# audio is returned as bytes\naudio = client.text_to_speech(\n {{ inputs.asObj.inputs }},\n model=\"{{ model.id }}\",\n) \n",
|
|
43
45
|
"textToVideo": "video = client.text_to_video(\n {{ inputs.asObj.inputs }},\n model=\"{{ model.id }}\",\n) "
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AudioClassificationInput, AudioClassificationOutput } 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 type { LegacyAudioInput } from "./utils";
|
|
7
|
-
import { preparePayload } 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 type { LegacyAudioInput } from "./utils.js";
|
|
7
|
+
import { preparePayload } from "./utils.js";
|
|
8
8
|
|
|
9
9
|
export type AudioClassificationArgs = BaseArgs & (AudioClassificationInput | LegacyAudioInput);
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
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";
|
|
5
|
-
import type { LegacyAudioInput } from "./utils";
|
|
6
|
-
import { preparePayload } from "./utils";
|
|
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
|
+
import type { LegacyAudioInput } from "./utils.js";
|
|
6
|
+
import { preparePayload } from "./utils.js";
|
|
7
7
|
|
|
8
8
|
export type AudioToAudioArgs =
|
|
9
9
|
| (BaseArgs & {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput } from "@huggingface/tasks";
|
|
2
|
-
import { resolveProvider } from "../../lib/getInferenceProviderMapping";
|
|
3
|
-
import { getProviderHelper } from "../../lib/getProviderHelper";
|
|
4
|
-
import { InferenceOutputError } from "../../lib/InferenceOutputError";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { omit } from "../../utils/omit";
|
|
9
|
-
import { innerRequest } from "../../utils/request";
|
|
10
|
-
import type { LegacyAudioInput } from "./utils";
|
|
11
|
-
import { preparePayload } from "./utils";
|
|
2
|
+
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js";
|
|
3
|
+
import { getProviderHelper } from "../../lib/getProviderHelper.js";
|
|
4
|
+
import { InferenceOutputError } from "../../lib/InferenceOutputError.js";
|
|
5
|
+
import type { BaseArgs, Options } from "../../types.js";
|
|
6
|
+
import { innerRequest } from "../../utils/request.js";
|
|
7
|
+
import type { LegacyAudioInput } from "./utils.js";
|
|
12
8
|
|
|
13
9
|
export type AutomaticSpeechRecognitionArgs = BaseArgs & (AutomaticSpeechRecognitionInput | LegacyAudioInput);
|
|
14
10
|
/**
|
|
@@ -21,7 +17,7 @@ export async function automaticSpeechRecognition(
|
|
|
21
17
|
): Promise<AutomaticSpeechRecognitionOutput> {
|
|
22
18
|
const provider = await resolveProvider(args.provider, args.model, args.endpointUrl);
|
|
23
19
|
const providerHelper = getProviderHelper(provider, "automatic-speech-recognition");
|
|
24
|
-
const payload = await
|
|
20
|
+
const payload = await providerHelper.preparePayloadAsync(args);
|
|
25
21
|
const { data: res } = await innerRequest<AutomaticSpeechRecognitionOutput>(payload, providerHelper, {
|
|
26
22
|
...options,
|
|
27
23
|
task: "automatic-speech-recognition",
|
|
@@ -32,29 +28,3 @@ export async function automaticSpeechRecognition(
|
|
|
32
28
|
}
|
|
33
29
|
return providerHelper.getResponse(res);
|
|
34
30
|
}
|
|
35
|
-
|
|
36
|
-
async function buildPayload(args: AutomaticSpeechRecognitionArgs): Promise<RequestArgs> {
|
|
37
|
-
if (args.provider === "fal-ai") {
|
|
38
|
-
const blob = "data" in args && args.data instanceof Blob ? args.data : "inputs" in args ? args.inputs : undefined;
|
|
39
|
-
const contentType = blob?.type;
|
|
40
|
-
if (!contentType) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
`Unable to determine the input's content-type. Make sure your are passing a Blob when using provider fal-ai.`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (!FAL_AI_SUPPORTED_BLOB_TYPES.includes(contentType)) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`Provider fal-ai does not support blob type ${contentType} - supported content types are: ${FAL_AI_SUPPORTED_BLOB_TYPES.join(
|
|
48
|
-
", "
|
|
49
|
-
)}`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
const base64audio = base64FromBytes(new Uint8Array(await blob.arrayBuffer()));
|
|
53
|
-
return {
|
|
54
|
-
...("data" in args ? omit(args, "data") : omit(args, "inputs")),
|
|
55
|
-
audio_url: `data:${contentType};base64,${base64audio}`,
|
|
56
|
-
};
|
|
57
|
-
} else {
|
|
58
|
-
return preparePayload(args);
|
|
59
|
-
}
|
|
60
|
-
}
|