@huggingface/tasks 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ declare enum ModelLibrary {
23
23
  "pyannote-audio" = "pyannote.audio",
24
24
  "sample-factory" = "Sample Factory",
25
25
  "sentence-transformers" = "Sentence Transformers",
26
+ "setfit" = "SetFit",
26
27
  "sklearn" = "Scikit-learn",
27
28
  "spacy" = "spaCy",
28
29
  "span-marker" = "SpanMarker",
@@ -452,6 +453,9 @@ declare const PIPELINE_TYPES_SET: Set<"other" | "text-classification" | "token-c
452
453
  */
453
454
  declare const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLibraryKey, PipelineType[]>>;
454
455
 
456
+ /**
457
+ * See default-widget-inputs.ts for the default widget inputs, this files only contains the types
458
+ */
455
459
  type TableData = Record<string, (string | number)[]>;
456
460
  type WidgetExampleOutputLabels = Array<{
457
461
  label: string;
@@ -526,6 +530,7 @@ interface WidgetExampleSentenceSimilarityInput<TOutput = WidgetExampleOutput> ex
526
530
  type WidgetExample<TOutput = WidgetExampleOutput> = WidgetExampleTextInput<TOutput> | WidgetExampleTextAndContextInput<TOutput> | WidgetExampleTextAndTableInput<TOutput> | WidgetExampleAssetInput<TOutput> | WidgetExampleAssetAndPromptInput<TOutput> | WidgetExampleAssetAndTextInput<TOutput> | WidgetExampleAssetAndZeroShotInput<TOutput> | WidgetExampleStructuredDataInput<TOutput> | WidgetExampleTableDataInput<TOutput> | WidgetExampleZeroShotTextInput<TOutput> | WidgetExampleSentenceSimilarityInput<TOutput>;
527
531
  type KeysOfUnion<T> = T extends unknown ? keyof T : never;
528
532
  type WidgetExampleAttribute = KeysOfUnion<WidgetExample>;
533
+
529
534
  declare enum InferenceDisplayability {
530
535
  /**
531
536
  * Yes
package/dist/index.js CHANGED
@@ -66,6 +66,7 @@ var LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS = {
66
66
  peft: ["text-generation"],
67
67
  "pyannote-audio": ["automatic-speech-recognition"],
68
68
  "sentence-transformers": ["feature-extraction", "sentence-similarity"],
69
+ setfit: ["text-classification"],
69
70
  sklearn: ["tabular-classification", "tabular-regression", "text-classification"],
70
71
  spacy: ["token-classification", "text-classification", "sentence-similarity"],
71
72
  "span-marker": ["token-classification"],
@@ -218,8 +219,8 @@ var paddlenlp = (model) => {
218
219
  [
219
220
  `from paddlenlp.transformers import AutoTokenizer, ${architecture}`,
220
221
  "",
221
- `tokenizer = AutoTokenizer.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`,
222
- `model = ${architecture}.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`
222
+ `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`,
223
+ `model = ${architecture}.from_pretrained("${model.id}", from_hf_hub=True)`
223
224
  ].join("\n")
224
225
  ];
225
226
  } else {
@@ -228,8 +229,8 @@ var paddlenlp = (model) => {
228
229
  `# \u26A0\uFE0F Type of model unknown`,
229
230
  `from paddlenlp.transformers import AutoTokenizer, AutoModel`,
230
231
  "",
231
- `tokenizer = AutoTokenizer.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`,
232
- `model = AutoModel.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`
232
+ `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`,
233
+ `model = AutoModel.from_pretrained("${model.id}", from_hf_hub=True)`
233
234
  ].join("\n")
234
235
  ];
235
236
  }
@@ -365,6 +366,11 @@ var sentenceTransformers = (model) => [
365
366
 
366
367
  model = SentenceTransformer("${model.id}")`
367
368
  ];
369
+ var setfit = (model) => [
370
+ `from setfit import SetFitModel
371
+
372
+ model = SetFitModel.from_pretrained("${model.id}")`
373
+ ];
368
374
  var spacy = (model) => [
369
375
  `!pip install https://huggingface.co/${model.id}/resolve/main/${nameWithoutNamespace(model.id)}-any-py3-none-any.whl
370
376
 
@@ -637,6 +643,13 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
637
643
  docsUrl: "https://huggingface.co/docs/hub/sentence-transformers",
638
644
  snippets: sentenceTransformers
639
645
  },
646
+ setfit: {
647
+ btnLabel: "setfit",
648
+ repoName: "setfit",
649
+ repoUrl: "https://github.com/huggingface/setfit",
650
+ docsUrl: "https://huggingface.co/docs/hub/setfit",
651
+ snippets: setfit
652
+ },
640
653
  sklearn: {
641
654
  btnLabel: "Scikit-learn",
642
655
  repoName: "Scikit-learn",
@@ -4459,7 +4472,7 @@ var TASKS_MODEL_LIBRARIES = {
4459
4472
  "tabular-classification": ["sklearn"],
4460
4473
  "tabular-regression": ["sklearn"],
4461
4474
  "tabular-to-text": ["transformers"],
4462
- "text-classification": ["adapter-transformers", "spacy", "transformers", "transformers.js"],
4475
+ "text-classification": ["adapter-transformers", "setfit", "spacy", "transformers", "transformers.js"],
4463
4476
  "text-generation": ["transformers", "transformers.js"],
4464
4477
  "text-retrieval": [],
4465
4478
  "text-to-image": ["diffusers"],
@@ -4566,6 +4579,7 @@ var ModelLibrary = /* @__PURE__ */ ((ModelLibrary2) => {
4566
4579
  ModelLibrary2["pyannote-audio"] = "pyannote.audio";
4567
4580
  ModelLibrary2["sample-factory"] = "Sample Factory";
4568
4581
  ModelLibrary2["sentence-transformers"] = "Sentence Transformers";
4582
+ ModelLibrary2["setfit"] = "SetFit";
4569
4583
  ModelLibrary2["sklearn"] = "Scikit-learn";
4570
4584
  ModelLibrary2["spacy"] = "spaCy";
4571
4585
  ModelLibrary2["span-marker"] = "SpanMarker";
package/dist/index.mjs CHANGED
@@ -28,6 +28,7 @@ var LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS = {
28
28
  peft: ["text-generation"],
29
29
  "pyannote-audio": ["automatic-speech-recognition"],
30
30
  "sentence-transformers": ["feature-extraction", "sentence-similarity"],
31
+ setfit: ["text-classification"],
31
32
  sklearn: ["tabular-classification", "tabular-regression", "text-classification"],
32
33
  spacy: ["token-classification", "text-classification", "sentence-similarity"],
33
34
  "span-marker": ["token-classification"],
@@ -180,8 +181,8 @@ var paddlenlp = (model) => {
180
181
  [
181
182
  `from paddlenlp.transformers import AutoTokenizer, ${architecture}`,
182
183
  "",
183
- `tokenizer = AutoTokenizer.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`,
184
- `model = ${architecture}.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`
184
+ `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`,
185
+ `model = ${architecture}.from_pretrained("${model.id}", from_hf_hub=True)`
185
186
  ].join("\n")
186
187
  ];
187
188
  } else {
@@ -190,8 +191,8 @@ var paddlenlp = (model) => {
190
191
  `# \u26A0\uFE0F Type of model unknown`,
191
192
  `from paddlenlp.transformers import AutoTokenizer, AutoModel`,
192
193
  "",
193
- `tokenizer = AutoTokenizer.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`,
194
- `model = AutoModel.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`
194
+ `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`,
195
+ `model = AutoModel.from_pretrained("${model.id}", from_hf_hub=True)`
195
196
  ].join("\n")
196
197
  ];
197
198
  }
@@ -327,6 +328,11 @@ var sentenceTransformers = (model) => [
327
328
 
328
329
  model = SentenceTransformer("${model.id}")`
329
330
  ];
331
+ var setfit = (model) => [
332
+ `from setfit import SetFitModel
333
+
334
+ model = SetFitModel.from_pretrained("${model.id}")`
335
+ ];
330
336
  var spacy = (model) => [
331
337
  `!pip install https://huggingface.co/${model.id}/resolve/main/${nameWithoutNamespace(model.id)}-any-py3-none-any.whl
332
338
 
@@ -599,6 +605,13 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
599
605
  docsUrl: "https://huggingface.co/docs/hub/sentence-transformers",
600
606
  snippets: sentenceTransformers
601
607
  },
608
+ setfit: {
609
+ btnLabel: "setfit",
610
+ repoName: "setfit",
611
+ repoUrl: "https://github.com/huggingface/setfit",
612
+ docsUrl: "https://huggingface.co/docs/hub/setfit",
613
+ snippets: setfit
614
+ },
602
615
  sklearn: {
603
616
  btnLabel: "Scikit-learn",
604
617
  repoName: "Scikit-learn",
@@ -4421,7 +4434,7 @@ var TASKS_MODEL_LIBRARIES = {
4421
4434
  "tabular-classification": ["sklearn"],
4422
4435
  "tabular-regression": ["sklearn"],
4423
4436
  "tabular-to-text": ["transformers"],
4424
- "text-classification": ["adapter-transformers", "spacy", "transformers", "transformers.js"],
4437
+ "text-classification": ["adapter-transformers", "setfit", "spacy", "transformers", "transformers.js"],
4425
4438
  "text-generation": ["transformers", "transformers.js"],
4426
4439
  "text-retrieval": [],
4427
4440
  "text-to-image": ["diffusers"],
@@ -4528,6 +4541,7 @@ var ModelLibrary = /* @__PURE__ */ ((ModelLibrary2) => {
4528
4541
  ModelLibrary2["pyannote-audio"] = "pyannote.audio";
4529
4542
  ModelLibrary2["sample-factory"] = "Sample Factory";
4530
4543
  ModelLibrary2["sentence-transformers"] = "Sentence Transformers";
4544
+ ModelLibrary2["setfit"] = "SetFit";
4531
4545
  ModelLibrary2["sklearn"] = "Scikit-learn";
4532
4546
  ModelLibrary2["spacy"] = "spaCy";
4533
4547
  ModelLibrary2["span-marker"] = "SpanMarker";
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.0.9",
4
+ "version": "0.1.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": {
@@ -1,4 +1,4 @@
1
- import type { WidgetExample } from "./model-data";
1
+ import type { WidgetExample } from "./widget-example";
2
2
  import type { PipelineType } from "./pipelines";
3
3
 
4
4
  type LanguageCode = string;
package/src/index.ts CHANGED
@@ -16,9 +16,8 @@ export {
16
16
  } from "./pipelines";
17
17
  export { ModelLibrary, ALL_DISPLAY_MODEL_LIBRARY_KEYS } from "./model-libraries";
18
18
  export type { ModelLibraryKey } from "./model-libraries";
19
- export {
20
- ModelData,
21
- TransformersInfo,
19
+ export type { ModelData, TransformersInfo } from "./model-data";
20
+ export type {
22
21
  WidgetExample,
23
22
  WidgetExampleAttribute,
24
23
  WidgetExampleAssetAndPromptInput,
@@ -37,7 +36,7 @@ export {
37
36
  WidgetExampleOutputLabels,
38
37
  WidgetExampleOutputAnswerScore,
39
38
  WidgetExampleOutputText,
40
- } from "./model-data";
39
+ } from "./widget-example";
41
40
  export { InferenceDisplayability } from "./model-data";
42
41
 
43
42
  export { TAG_NFAA_CONTENT, OTHER_TAGS_SUGGESTIONS, TAG_TEXT_GENERATION_INFERENCE, TAG_CUSTOM_CODE } from "./tags";
@@ -31,6 +31,7 @@ export const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLi
31
31
  peft: ["text-generation"],
32
32
  "pyannote-audio": ["automatic-speech-recognition"],
33
33
  "sentence-transformers": ["feature-extraction", "sentence-similarity"],
34
+ setfit: ["text-classification"],
34
35
  sklearn: ["tabular-classification", "tabular-regression", "text-classification"],
35
36
  spacy: ["token-classification", "text-classification", "sentence-similarity"],
36
37
  "span-marker": ["token-classification"],
@@ -187,12 +187,8 @@ const paddlenlp = (model: ModelData) => {
187
187
  [
188
188
  `from paddlenlp.transformers import AutoTokenizer, ${architecture}`,
189
189
  "",
190
- `tokenizer = AutoTokenizer.from_pretrained("${model.id}"${
191
- model.private ? ", use_auth_token=True" : ""
192
- }, from_hf_hub=True)`,
193
- `model = ${architecture}.from_pretrained("${model.id}"${
194
- model.private ? ", use_auth_token=True" : ""
195
- }, from_hf_hub=True)`,
190
+ `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`,
191
+ `model = ${architecture}.from_pretrained("${model.id}", from_hf_hub=True)`,
196
192
  ].join("\n"),
197
193
  ];
198
194
  } else {
@@ -201,12 +197,8 @@ const paddlenlp = (model: ModelData) => {
201
197
  `# ⚠️ Type of model unknown`,
202
198
  `from paddlenlp.transformers import AutoTokenizer, AutoModel`,
203
199
  "",
204
- `tokenizer = AutoTokenizer.from_pretrained("${model.id}"${
205
- model.private ? ", use_auth_token=True" : ""
206
- }, from_hf_hub=True)`,
207
- `model = AutoModel.from_pretrained("${model.id}"${
208
- model.private ? ", use_auth_token=True" : ""
209
- }, from_hf_hub=True)`,
200
+ `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`,
201
+ `model = AutoModel.from_pretrained("${model.id}", from_hf_hub=True)`,
210
202
  ].join("\n"),
211
203
  ];
212
204
  }
@@ -358,6 +350,12 @@ const sentenceTransformers = (model: ModelData) => [
358
350
  model = SentenceTransformer("${model.id}")`,
359
351
  ];
360
352
 
353
+ const setfit = (model: ModelData) => [
354
+ `from setfit import SetFitModel
355
+
356
+ model = SetFitModel.from_pretrained("${model.id}")`,
357
+ ];
358
+
361
359
  const spacy = (model: ModelData) => [
362
360
  `!pip install https://huggingface.co/${model.id}/resolve/main/${nameWithoutNamespace(model.id)}-any-py3-none-any.whl
363
361
 
@@ -661,6 +659,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS: Partial<Record<ModelLibraryKey, Librar
661
659
  docsUrl: "https://huggingface.co/docs/hub/sentence-transformers",
662
660
  snippets: sentenceTransformers,
663
661
  },
662
+ setfit: {
663
+ btnLabel: "setfit",
664
+ repoName: "setfit",
665
+ repoUrl: "https://github.com/huggingface/setfit",
666
+ docsUrl: "https://huggingface.co/docs/hub/setfit",
667
+ snippets: setfit,
668
+ },
664
669
  sklearn: {
665
670
  btnLabel: "Scikit-learn",
666
671
  repoName: "Scikit-learn",
package/src/model-data.ts CHANGED
@@ -1,119 +1,5 @@
1
1
  import type { PipelineType } from "./pipelines";
2
-
3
- type TableData = Record<string, (string | number)[]>;
4
-
5
- //#region outputs
6
- export type WidgetExampleOutputLabels = Array<{ label: string; score: number }>;
7
- export interface WidgetExampleOutputAnswerScore {
8
- answer: string;
9
- score: number;
10
- }
11
- export interface WidgetExampleOutputText {
12
- text: string;
13
- }
14
- export interface WidgetExampleOutputUrl {
15
- url: string;
16
- }
17
-
18
- export type WidgetExampleOutput =
19
- | WidgetExampleOutputLabels
20
- | WidgetExampleOutputAnswerScore
21
- | WidgetExampleOutputText
22
- | WidgetExampleOutputUrl;
23
- //#endregion
24
-
25
- export interface WidgetExampleBase<TOutput> {
26
- example_title?: string;
27
- group?: string;
28
- /**
29
- * Potential overrides to API parameters for this specific example
30
- * (takes precedences over the model card metadata's inference.parameters)
31
- */
32
- parameters?: {
33
- /// token-classification
34
- aggregation_strategy?: string;
35
- /// text-generation
36
- top_k?: number;
37
- top_p?: number;
38
- temperature?: number;
39
- max_new_tokens?: number;
40
- do_sample?: boolean;
41
- /// text-to-image
42
- negative_prompt?: string;
43
- guidance_scale?: number;
44
- num_inference_steps?: number;
45
- };
46
- /**
47
- * Optional output
48
- */
49
- output?: TOutput;
50
- }
51
-
52
- export interface WidgetExampleTextInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
53
- text: string;
54
- }
55
-
56
- export interface WidgetExampleTextAndContextInput<TOutput = WidgetExampleOutput>
57
- extends WidgetExampleTextInput<TOutput> {
58
- context: string;
59
- }
60
-
61
- export interface WidgetExampleTextAndTableInput<TOutput = WidgetExampleOutput> extends WidgetExampleTextInput<TOutput> {
62
- table: TableData;
63
- }
64
-
65
- export interface WidgetExampleAssetInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
66
- src: string;
67
- }
68
- export interface WidgetExampleAssetAndPromptInput<TOutput = WidgetExampleOutput>
69
- extends WidgetExampleAssetInput<TOutput> {
70
- prompt: string;
71
- }
72
-
73
- export type WidgetExampleAssetAndTextInput<TOutput = WidgetExampleOutput> = WidgetExampleAssetInput<TOutput> &
74
- WidgetExampleTextInput<TOutput>;
75
-
76
- export type WidgetExampleAssetAndZeroShotInput<TOutput = WidgetExampleOutput> = WidgetExampleAssetInput<TOutput> &
77
- WidgetExampleZeroShotTextInput<TOutput>;
78
-
79
- export interface WidgetExampleStructuredDataInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
80
- structured_data: TableData;
81
- }
82
-
83
- export interface WidgetExampleTableDataInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
84
- table: TableData;
85
- }
86
-
87
- export interface WidgetExampleZeroShotTextInput<TOutput = WidgetExampleOutput> extends WidgetExampleTextInput<TOutput> {
88
- text: string;
89
- candidate_labels: string;
90
- multi_class: boolean;
91
- }
92
-
93
- export interface WidgetExampleSentenceSimilarityInput<TOutput = WidgetExampleOutput>
94
- extends WidgetExampleBase<TOutput> {
95
- source_sentence: string;
96
- sentences: string[];
97
- }
98
-
99
- //#endregion
100
-
101
- export type WidgetExample<TOutput = WidgetExampleOutput> =
102
- | WidgetExampleTextInput<TOutput>
103
- | WidgetExampleTextAndContextInput<TOutput>
104
- | WidgetExampleTextAndTableInput<TOutput>
105
- | WidgetExampleAssetInput<TOutput>
106
- | WidgetExampleAssetAndPromptInput<TOutput>
107
- | WidgetExampleAssetAndTextInput<TOutput>
108
- | WidgetExampleAssetAndZeroShotInput<TOutput>
109
- | WidgetExampleStructuredDataInput<TOutput>
110
- | WidgetExampleTableDataInput<TOutput>
111
- | WidgetExampleZeroShotTextInput<TOutput>
112
- | WidgetExampleSentenceSimilarityInput<TOutput>;
113
-
114
- type KeysOfUnion<T> = T extends unknown ? keyof T : never;
115
-
116
- export type WidgetExampleAttribute = KeysOfUnion<WidgetExample>;
2
+ import type { WidgetExample } from "./widget-example";
117
3
 
118
4
  export enum InferenceDisplayability {
119
5
  /**
@@ -23,6 +23,7 @@ export enum ModelLibrary {
23
23
  "pyannote-audio" = "pyannote.audio",
24
24
  "sample-factory" = "Sample Factory",
25
25
  "sentence-transformers" = "Sentence Transformers",
26
+ "setfit" = "SetFit",
26
27
  "sklearn" = "Scikit-learn",
27
28
  "spacy" = "spaCy",
28
29
  "span-marker" = "SpanMarker",
@@ -69,7 +69,7 @@ export const TASKS_MODEL_LIBRARIES: Record<PipelineType, ModelLibraryKey[]> = {
69
69
  "tabular-classification": ["sklearn"],
70
70
  "tabular-regression": ["sklearn"],
71
71
  "tabular-to-text": ["transformers"],
72
- "text-classification": ["adapter-transformers", "spacy", "transformers", "transformers.js"],
72
+ "text-classification": ["adapter-transformers", "setfit", "spacy", "transformers", "transformers.js"],
73
73
  "text-generation": ["transformers", "transformers.js"],
74
74
  "text-retrieval": [],
75
75
  "text-to-image": ["diffusers"],
@@ -0,0 +1,118 @@
1
+ /**
2
+ * See default-widget-inputs.ts for the default widget inputs, this files only contains the types
3
+ */
4
+
5
+ type TableData = Record<string, (string | number)[]>;
6
+
7
+ //#region outputs
8
+ export type WidgetExampleOutputLabels = Array<{ label: string; score: number }>;
9
+ export interface WidgetExampleOutputAnswerScore {
10
+ answer: string;
11
+ score: number;
12
+ }
13
+ export interface WidgetExampleOutputText {
14
+ text: string;
15
+ }
16
+ export interface WidgetExampleOutputUrl {
17
+ url: string;
18
+ }
19
+
20
+ export type WidgetExampleOutput =
21
+ | WidgetExampleOutputLabels
22
+ | WidgetExampleOutputAnswerScore
23
+ | WidgetExampleOutputText
24
+ | WidgetExampleOutputUrl;
25
+ //#endregion
26
+
27
+ export interface WidgetExampleBase<TOutput> {
28
+ example_title?: string;
29
+ group?: string;
30
+ /**
31
+ * Potential overrides to API parameters for this specific example
32
+ * (takes precedences over the model card metadata's inference.parameters)
33
+ */
34
+ parameters?: {
35
+ /// token-classification
36
+ aggregation_strategy?: string;
37
+ /// text-generation
38
+ top_k?: number;
39
+ top_p?: number;
40
+ temperature?: number;
41
+ max_new_tokens?: number;
42
+ do_sample?: boolean;
43
+ /// text-to-image
44
+ negative_prompt?: string;
45
+ guidance_scale?: number;
46
+ num_inference_steps?: number;
47
+ };
48
+ /**
49
+ * Optional output
50
+ */
51
+ output?: TOutput;
52
+ }
53
+
54
+ export interface WidgetExampleTextInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
55
+ text: string;
56
+ }
57
+
58
+ export interface WidgetExampleTextAndContextInput<TOutput = WidgetExampleOutput>
59
+ extends WidgetExampleTextInput<TOutput> {
60
+ context: string;
61
+ }
62
+
63
+ export interface WidgetExampleTextAndTableInput<TOutput = WidgetExampleOutput> extends WidgetExampleTextInput<TOutput> {
64
+ table: TableData;
65
+ }
66
+
67
+ export interface WidgetExampleAssetInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
68
+ src: string;
69
+ }
70
+ export interface WidgetExampleAssetAndPromptInput<TOutput = WidgetExampleOutput>
71
+ extends WidgetExampleAssetInput<TOutput> {
72
+ prompt: string;
73
+ }
74
+
75
+ export type WidgetExampleAssetAndTextInput<TOutput = WidgetExampleOutput> = WidgetExampleAssetInput<TOutput> &
76
+ WidgetExampleTextInput<TOutput>;
77
+
78
+ export type WidgetExampleAssetAndZeroShotInput<TOutput = WidgetExampleOutput> = WidgetExampleAssetInput<TOutput> &
79
+ WidgetExampleZeroShotTextInput<TOutput>;
80
+
81
+ export interface WidgetExampleStructuredDataInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
82
+ structured_data: TableData;
83
+ }
84
+
85
+ export interface WidgetExampleTableDataInput<TOutput = WidgetExampleOutput> extends WidgetExampleBase<TOutput> {
86
+ table: TableData;
87
+ }
88
+
89
+ export interface WidgetExampleZeroShotTextInput<TOutput = WidgetExampleOutput> extends WidgetExampleTextInput<TOutput> {
90
+ text: string;
91
+ candidate_labels: string;
92
+ multi_class: boolean;
93
+ }
94
+
95
+ export interface WidgetExampleSentenceSimilarityInput<TOutput = WidgetExampleOutput>
96
+ extends WidgetExampleBase<TOutput> {
97
+ source_sentence: string;
98
+ sentences: string[];
99
+ }
100
+
101
+ //#endregion
102
+
103
+ export type WidgetExample<TOutput = WidgetExampleOutput> =
104
+ | WidgetExampleTextInput<TOutput>
105
+ | WidgetExampleTextAndContextInput<TOutput>
106
+ | WidgetExampleTextAndTableInput<TOutput>
107
+ | WidgetExampleAssetInput<TOutput>
108
+ | WidgetExampleAssetAndPromptInput<TOutput>
109
+ | WidgetExampleAssetAndTextInput<TOutput>
110
+ | WidgetExampleAssetAndZeroShotInput<TOutput>
111
+ | WidgetExampleStructuredDataInput<TOutput>
112
+ | WidgetExampleTableDataInput<TOutput>
113
+ | WidgetExampleZeroShotTextInput<TOutput>
114
+ | WidgetExampleSentenceSimilarityInput<TOutput>;
115
+
116
+ type KeysOfUnion<T> = T extends unknown ? keyof T : never;
117
+
118
+ export type WidgetExampleAttribute = KeysOfUnion<WidgetExample>;