@huggingface/tasks 0.7.0 → 0.8.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/index.cjs CHANGED
@@ -81,15 +81,24 @@ var LIBRARY_TASK_MAPPING = {
81
81
  "automatic-speech-recognition",
82
82
  "depth-estimation",
83
83
  "document-question-answering",
84
+ "feature-extraction",
84
85
  "fill-mask",
85
86
  "image-classification",
86
87
  "image-segmentation",
87
- "image-to-text",
88
88
  "image-to-image",
89
+ "image-to-text",
89
90
  "object-detection",
90
91
  "question-answering",
91
- "text-generation",
92
+ "summarization",
93
+ "table-question-answering",
92
94
  "text2text-generation",
95
+ "text-classification",
96
+ "text-generation",
97
+ "text-to-audio",
98
+ "text-to-speech",
99
+ "token-classification",
100
+ "translation",
101
+ "video-classification",
93
102
  "visual-question-answering",
94
103
  "zero-shot-classification",
95
104
  "zero-shot-image-classification"
package/dist/index.d.ts CHANGED
@@ -507,7 +507,10 @@ type SpecialTokensMap = {
507
507
  */
508
508
  interface TokenizerConfig extends SpecialTokensMap {
509
509
  use_default_system_prompt?: boolean;
510
- chat_template?: string;
510
+ chat_template?: string | Array<{
511
+ name: string;
512
+ template: string;
513
+ }>;
511
514
  }
512
515
 
513
516
  declare enum InferenceDisplayability {
@@ -1149,7 +1152,7 @@ declare const ALL_DISPLAY_MODEL_LIBRARY_KEYS: ("sklearn" | "adapter-transformers
1149
1152
  * Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
1150
1153
  * This mapping is partially generated automatically by "python-api-export-tasks" action in
1151
1154
  * huggingface/api-inference-community repo upon merge. For transformers, the mapping is manually
1152
- * based on api-inference.
1155
+ * based on api-inference (hf_types.rs).
1153
1156
  */
1154
1157
  declare const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[]>>;
1155
1158
 
@@ -2977,6 +2980,46 @@ interface TextGenerationOutputToken {
2977
2980
  text: string;
2978
2981
  [property: string]: unknown;
2979
2982
  }
2983
+ /**
2984
+ * Text Generation Stream Output
2985
+ */
2986
+ interface TextGenerationStreamOutput {
2987
+ /**
2988
+ * Generation details. Only available when the generation is finished.
2989
+ */
2990
+ details?: TextGenerationStreamDetails;
2991
+ /**
2992
+ * The complete generated text. Only available when the generation is finished.
2993
+ */
2994
+ generated_text?: string;
2995
+ /**
2996
+ * The token index within the stream. Optional to support older clients that omit it.
2997
+ */
2998
+ index?: number;
2999
+ /**
3000
+ * Generated token.
3001
+ */
3002
+ token: TextGenerationOutputToken;
3003
+ [property: string]: unknown;
3004
+ }
3005
+ /**
3006
+ * Generation details. Only available when the generation is finished.
3007
+ */
3008
+ interface TextGenerationStreamDetails {
3009
+ /**
3010
+ * The reason why the generation was stopped.
3011
+ */
3012
+ finish_reason: TextGenerationFinishReason;
3013
+ /**
3014
+ * The number of generated tokens
3015
+ */
3016
+ generated_tokens: number;
3017
+ /**
3018
+ * The random seed used for generation
3019
+ */
3020
+ seed: number;
3021
+ [property: string]: unknown;
3022
+ }
2980
3023
 
2981
3024
  /**
2982
3025
  * Inference code generated from the JSON schema spec in ./spec
@@ -3471,4 +3514,4 @@ declare namespace index {
3471
3514
  };
3472
3515
  }
3473
3516
 
3474
- export { ALL_DISPLAY_MODEL_LIBRARY_KEYS, ALL_MODEL_LIBRARY_KEYS, AddedToken, AudioClassificationInput, AudioClassificationOutput, AudioClassificationOutputElement, AudioClassificationParameters, AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput, AutomaticSpeechRecognitionOutputChunk, AutomaticSpeechRecognitionParameters, BoundingBox, ChatCompletionFinishReason, ChatCompletionInput, ChatCompletionInputMessage, ChatCompletionOutput, ChatCompletionOutputChoice, ChatCompletionOutputChoiceMessage, ChatCompletionStreamOutput, ChatCompletionStreamOutputChoice, ChatCompletionStreamOutputDelta, ChatMessage, ClassificationOutputTransform$1 as ClassificationOutputTransform, DepthEstimationInput, DepthEstimationOutput, DocumentQuestionAnsweringInput, DocumentQuestionAnsweringInputData, DocumentQuestionAnsweringOutput, DocumentQuestionAnsweringOutputElement, DocumentQuestionAnsweringParameters, EarlyStoppingUnion$2 as EarlyStoppingUnion, ExampleRepo, FeatureExtractionInput, FeatureExtractionOutput, FillMaskInput, FillMaskOutput, FillMaskOutputElement, FillMaskParameters, GenerationParameters$2 as GenerationParameters, ImageClassificationInput, ImageClassificationOutput, ImageClassificationOutputElement, ImageClassificationParameters, ImageSegmentationInput, ImageSegmentationOutput, ImageSegmentationOutputElement, ImageSegmentationParameters, ImageSegmentationSubtask, ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToTextInput, ImageToTextOutput, ImageToTextParameters, InferenceDisplayability, LIBRARY_TASK_MAPPING, LibraryUiElement, MAPPING_DEFAULT_WIDGET, MODALITIES, MODALITY_LABELS, MODEL_LIBRARIES_UI_ELEMENTS, Modality, ModelData, ModelLibraryKey, ObjectDetectionInput, ObjectDetectionOutput, ObjectDetectionOutputElement, ObjectDetectionParameters, PIPELINE_DATA, PIPELINE_TYPES, PIPELINE_TYPES_SET, PipelineData, PipelineType, QuestionAnsweringInput, QuestionAnsweringInputData, QuestionAnsweringOutput, QuestionAnsweringOutputElement, QuestionAnsweringParameters, SPECIAL_TOKENS_ATTRIBUTES, SUBTASK_TYPES, SentenceSimilarityInput, SentenceSimilarityInputData, SentenceSimilarityOutput, SpecialTokensMap, SummarizationInput, SummarizationOutput, TASKS_DATA, TASKS_MODEL_LIBRARIES, TableQuestionAnsweringInput, TableQuestionAnsweringInputData, TableQuestionAnsweringOutput, TableQuestionAnsweringOutputElement, TargetSize$1 as TargetSize, TaskData, TaskDataCustom, TaskDemo, TaskDemoEntry, Text2TextGenerationParameters, Text2TextGenerationTruncationStrategy, TextClassificationInput, TextClassificationOutput, TextClassificationOutputElement, TextClassificationParameters, TextGenerationFinishReason, TextGenerationInput, TextGenerationOutput, TextGenerationOutputDetails, TextGenerationOutputSequenceDetails, TextGenerationOutputToken, TextGenerationParameters, TextGenerationPrefillToken, TextToAudioParameters, TextToImageInput, TextToImageOutput, TextToImageParameters, TextToSpeechInput, TextToSpeechOutput, TokenClassificationAggregationStrategy, TokenClassificationInput, TokenClassificationOutput, TokenClassificationOutputElement, TokenClassificationParameters, TokenizerConfig, TransformersInfo, TranslationInput, TranslationOutput, VideoClassificationInput, VideoClassificationOutput, VideoClassificationOutputElement, VideoClassificationParameters, VisualQuestionAnsweringInput, VisualQuestionAnsweringInputData, VisualQuestionAnsweringOutput, VisualQuestionAnsweringOutputElement, VisualQuestionAnsweringParameters, WidgetExample, WidgetExampleAssetAndPromptInput, WidgetExampleAssetAndTextInput, WidgetExampleAssetAndZeroShotInput, WidgetExampleAssetInput, WidgetExampleAttribute, WidgetExampleChatInput, WidgetExampleOutput, WidgetExampleOutputAnswerScore, WidgetExampleOutputLabels, WidgetExampleOutputText, WidgetExampleOutputUrl, WidgetExampleSentenceSimilarityInput, WidgetExampleStructuredDataInput, WidgetExampleTableDataInput, WidgetExampleTextAndContextInput, WidgetExampleTextAndTableInput, WidgetExampleTextInput, WidgetExampleZeroShotTextInput, WidgetType, WordBox, ZeroShotClassificationInput, ZeroShotClassificationInputData, ZeroShotClassificationOutput, ZeroShotClassificationOutputElement, ZeroShotClassificationParameters, ZeroShotImageClassificationInput, ZeroShotImageClassificationInputData, ZeroShotImageClassificationOutput, ZeroShotImageClassificationOutputElement, ZeroShotImageClassificationParameters, ZeroShotObjectDetectionInput, ZeroShotObjectDetectionInputData, ZeroShotObjectDetectionOutput, ZeroShotObjectDetectionOutputElement, index as snippets };
3517
+ export { ALL_DISPLAY_MODEL_LIBRARY_KEYS, ALL_MODEL_LIBRARY_KEYS, AddedToken, AudioClassificationInput, AudioClassificationOutput, AudioClassificationOutputElement, AudioClassificationParameters, AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput, AutomaticSpeechRecognitionOutputChunk, AutomaticSpeechRecognitionParameters, BoundingBox, ChatCompletionFinishReason, ChatCompletionInput, ChatCompletionInputMessage, ChatCompletionOutput, ChatCompletionOutputChoice, ChatCompletionOutputChoiceMessage, ChatCompletionStreamOutput, ChatCompletionStreamOutputChoice, ChatCompletionStreamOutputDelta, ChatMessage, ClassificationOutputTransform$1 as ClassificationOutputTransform, DepthEstimationInput, DepthEstimationOutput, DocumentQuestionAnsweringInput, DocumentQuestionAnsweringInputData, DocumentQuestionAnsweringOutput, DocumentQuestionAnsweringOutputElement, DocumentQuestionAnsweringParameters, EarlyStoppingUnion$2 as EarlyStoppingUnion, ExampleRepo, FeatureExtractionInput, FeatureExtractionOutput, FillMaskInput, FillMaskOutput, FillMaskOutputElement, FillMaskParameters, GenerationParameters$2 as GenerationParameters, ImageClassificationInput, ImageClassificationOutput, ImageClassificationOutputElement, ImageClassificationParameters, ImageSegmentationInput, ImageSegmentationOutput, ImageSegmentationOutputElement, ImageSegmentationParameters, ImageSegmentationSubtask, ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToTextInput, ImageToTextOutput, ImageToTextParameters, InferenceDisplayability, LIBRARY_TASK_MAPPING, LibraryUiElement, MAPPING_DEFAULT_WIDGET, MODALITIES, MODALITY_LABELS, MODEL_LIBRARIES_UI_ELEMENTS, Modality, ModelData, ModelLibraryKey, ObjectDetectionInput, ObjectDetectionOutput, ObjectDetectionOutputElement, ObjectDetectionParameters, PIPELINE_DATA, PIPELINE_TYPES, PIPELINE_TYPES_SET, PipelineData, PipelineType, QuestionAnsweringInput, QuestionAnsweringInputData, QuestionAnsweringOutput, QuestionAnsweringOutputElement, QuestionAnsweringParameters, SPECIAL_TOKENS_ATTRIBUTES, SUBTASK_TYPES, SentenceSimilarityInput, SentenceSimilarityInputData, SentenceSimilarityOutput, SpecialTokensMap, SummarizationInput, SummarizationOutput, TASKS_DATA, TASKS_MODEL_LIBRARIES, TableQuestionAnsweringInput, TableQuestionAnsweringInputData, TableQuestionAnsweringOutput, TableQuestionAnsweringOutputElement, TargetSize$1 as TargetSize, TaskData, TaskDataCustom, TaskDemo, TaskDemoEntry, Text2TextGenerationParameters, Text2TextGenerationTruncationStrategy, TextClassificationInput, TextClassificationOutput, TextClassificationOutputElement, TextClassificationParameters, TextGenerationFinishReason, TextGenerationInput, TextGenerationOutput, TextGenerationOutputDetails, TextGenerationOutputSequenceDetails, TextGenerationOutputToken, TextGenerationParameters, TextGenerationPrefillToken, TextGenerationStreamDetails, TextGenerationStreamOutput, TextToAudioParameters, TextToImageInput, TextToImageOutput, TextToImageParameters, TextToSpeechInput, TextToSpeechOutput, TokenClassificationAggregationStrategy, TokenClassificationInput, TokenClassificationOutput, TokenClassificationOutputElement, TokenClassificationParameters, TokenizerConfig, TransformersInfo, TranslationInput, TranslationOutput, VideoClassificationInput, VideoClassificationOutput, VideoClassificationOutputElement, VideoClassificationParameters, VisualQuestionAnsweringInput, VisualQuestionAnsweringInputData, VisualQuestionAnsweringOutput, VisualQuestionAnsweringOutputElement, VisualQuestionAnsweringParameters, WidgetExample, WidgetExampleAssetAndPromptInput, WidgetExampleAssetAndTextInput, WidgetExampleAssetAndZeroShotInput, WidgetExampleAssetInput, WidgetExampleAttribute, WidgetExampleChatInput, WidgetExampleOutput, WidgetExampleOutputAnswerScore, WidgetExampleOutputLabels, WidgetExampleOutputText, WidgetExampleOutputUrl, WidgetExampleSentenceSimilarityInput, WidgetExampleStructuredDataInput, WidgetExampleTableDataInput, WidgetExampleTextAndContextInput, WidgetExampleTextAndTableInput, WidgetExampleTextInput, WidgetExampleZeroShotTextInput, WidgetType, WordBox, ZeroShotClassificationInput, ZeroShotClassificationInputData, ZeroShotClassificationOutput, ZeroShotClassificationOutputElement, ZeroShotClassificationParameters, ZeroShotImageClassificationInput, ZeroShotImageClassificationInputData, ZeroShotImageClassificationOutput, ZeroShotImageClassificationOutputElement, ZeroShotImageClassificationParameters, ZeroShotObjectDetectionInput, ZeroShotObjectDetectionInputData, ZeroShotObjectDetectionOutput, ZeroShotObjectDetectionOutputElement, index as snippets };
package/dist/index.js CHANGED
@@ -46,15 +46,24 @@ var LIBRARY_TASK_MAPPING = {
46
46
  "automatic-speech-recognition",
47
47
  "depth-estimation",
48
48
  "document-question-answering",
49
+ "feature-extraction",
49
50
  "fill-mask",
50
51
  "image-classification",
51
52
  "image-segmentation",
52
- "image-to-text",
53
53
  "image-to-image",
54
+ "image-to-text",
54
55
  "object-detection",
55
56
  "question-answering",
56
- "text-generation",
57
+ "summarization",
58
+ "table-question-answering",
57
59
  "text2text-generation",
60
+ "text-classification",
61
+ "text-generation",
62
+ "text-to-audio",
63
+ "text-to-speech",
64
+ "token-classification",
65
+ "translation",
66
+ "video-classification",
58
67
  "visual-question-answering",
59
68
  "zero-shot-classification",
60
69
  "zero-shot-image-classification"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@huggingface/tasks",
3
3
  "packageManager": "pnpm@8.10.5",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "description": "List of ML tasks for huggingface.co/tasks",
6
6
  "repository": "https://github.com/huggingface/huggingface.js.git",
7
7
  "publishConfig": {
@@ -6,7 +6,7 @@ import type { PipelineType } from "./pipelines";
6
6
  * Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
7
7
  * This mapping is partially generated automatically by "python-api-export-tasks" action in
8
8
  * huggingface/api-inference-community repo upon merge. For transformers, the mapping is manually
9
- * based on api-inference.
9
+ * based on api-inference (hf_types.rs).
10
10
  */
11
11
  export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[]>> = {
12
12
  "adapter-transformers": ["question-answering", "text-classification", "token-classification"],
@@ -49,15 +49,24 @@ export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[
49
49
  "automatic-speech-recognition",
50
50
  "depth-estimation",
51
51
  "document-question-answering",
52
+ "feature-extraction",
52
53
  "fill-mask",
53
54
  "image-classification",
54
55
  "image-segmentation",
55
- "image-to-text",
56
56
  "image-to-image",
57
+ "image-to-text",
57
58
  "object-detection",
58
59
  "question-answering",
59
- "text-generation",
60
+ "summarization",
61
+ "table-question-answering",
60
62
  "text2text-generation",
63
+ "text-classification",
64
+ "text-generation",
65
+ "text-to-audio",
66
+ "text-to-speech",
67
+ "token-classification",
68
+ "translation",
69
+ "video-classification",
61
70
  "visual-question-answering",
62
71
  "zero-shot-classification",
63
72
  "zero-shot-image-classification",
@@ -92,6 +92,8 @@ export type {
92
92
  TextGenerationParameters,
93
93
  TextGenerationOutputSequenceDetails,
94
94
  TextGenerationOutputToken,
95
+ TextGenerationStreamDetails,
96
+ TextGenerationStreamOutput,
95
97
  } from "./text-generation/inference";
96
98
  export type * from "./video-classification/inference";
97
99
  export type * from "./visual-question-answering/inference";
@@ -28,5 +28,5 @@ export type SpecialTokensMap = {
28
28
  */
29
29
  export interface TokenizerConfig extends SpecialTokensMap {
30
30
  use_default_system_prompt?: boolean;
31
- chat_template?: string;
31
+ chat_template?: string | Array<{ name: string; template: string }>;
32
32
  }