@huggingface/tasks 0.13.1-test → 0.13.1-test2

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.
Files changed (198) hide show
  1. package/package.json +4 -2
  2. package/src/dataset-libraries.ts +89 -0
  3. package/src/default-widget-inputs.ts +718 -0
  4. package/src/gguf.ts +40 -0
  5. package/src/hardware.ts +482 -0
  6. package/src/index.ts +59 -0
  7. package/src/library-to-tasks.ts +76 -0
  8. package/src/local-apps.ts +412 -0
  9. package/src/model-data.ts +149 -0
  10. package/src/model-libraries-downloads.ts +18 -0
  11. package/src/model-libraries-snippets.ts +1128 -0
  12. package/src/model-libraries.ts +820 -0
  13. package/src/pipelines.ts +698 -0
  14. package/src/snippets/common.ts +39 -0
  15. package/src/snippets/curl.spec.ts +94 -0
  16. package/src/snippets/curl.ts +120 -0
  17. package/src/snippets/index.ts +7 -0
  18. package/src/snippets/inputs.ts +167 -0
  19. package/src/snippets/js.spec.ts +148 -0
  20. package/src/snippets/js.ts +305 -0
  21. package/src/snippets/python.spec.ts +144 -0
  22. package/src/snippets/python.ts +321 -0
  23. package/src/snippets/types.ts +16 -0
  24. package/src/tasks/audio-classification/about.md +86 -0
  25. package/src/tasks/audio-classification/data.ts +81 -0
  26. package/src/tasks/audio-classification/inference.ts +52 -0
  27. package/src/tasks/audio-classification/spec/input.json +35 -0
  28. package/src/tasks/audio-classification/spec/output.json +11 -0
  29. package/src/tasks/audio-to-audio/about.md +56 -0
  30. package/src/tasks/audio-to-audio/data.ts +70 -0
  31. package/src/tasks/automatic-speech-recognition/about.md +90 -0
  32. package/src/tasks/automatic-speech-recognition/data.ts +82 -0
  33. package/src/tasks/automatic-speech-recognition/inference.ts +160 -0
  34. package/src/tasks/automatic-speech-recognition/spec/input.json +35 -0
  35. package/src/tasks/automatic-speech-recognition/spec/output.json +38 -0
  36. package/src/tasks/chat-completion/inference.ts +322 -0
  37. package/src/tasks/chat-completion/spec/input.json +350 -0
  38. package/src/tasks/chat-completion/spec/output.json +206 -0
  39. package/src/tasks/chat-completion/spec/stream_output.json +213 -0
  40. package/src/tasks/common-definitions.json +100 -0
  41. package/src/tasks/depth-estimation/about.md +45 -0
  42. package/src/tasks/depth-estimation/data.ts +70 -0
  43. package/src/tasks/depth-estimation/inference.ts +35 -0
  44. package/src/tasks/depth-estimation/spec/input.json +25 -0
  45. package/src/tasks/depth-estimation/spec/output.json +16 -0
  46. package/src/tasks/document-question-answering/about.md +53 -0
  47. package/src/tasks/document-question-answering/data.ts +85 -0
  48. package/src/tasks/document-question-answering/inference.ts +110 -0
  49. package/src/tasks/document-question-answering/spec/input.json +85 -0
  50. package/src/tasks/document-question-answering/spec/output.json +36 -0
  51. package/src/tasks/feature-extraction/about.md +72 -0
  52. package/src/tasks/feature-extraction/data.ts +57 -0
  53. package/src/tasks/feature-extraction/inference.ts +40 -0
  54. package/src/tasks/feature-extraction/spec/input.json +47 -0
  55. package/src/tasks/feature-extraction/spec/output.json +15 -0
  56. package/src/tasks/fill-mask/about.md +51 -0
  57. package/src/tasks/fill-mask/data.ts +79 -0
  58. package/src/tasks/fill-mask/inference.ts +62 -0
  59. package/src/tasks/fill-mask/spec/input.json +38 -0
  60. package/src/tasks/fill-mask/spec/output.json +29 -0
  61. package/src/tasks/image-classification/about.md +50 -0
  62. package/src/tasks/image-classification/data.ts +88 -0
  63. package/src/tasks/image-classification/inference.ts +52 -0
  64. package/src/tasks/image-classification/spec/input.json +35 -0
  65. package/src/tasks/image-classification/spec/output.json +11 -0
  66. package/src/tasks/image-feature-extraction/about.md +23 -0
  67. package/src/tasks/image-feature-extraction/data.ts +59 -0
  68. package/src/tasks/image-segmentation/about.md +63 -0
  69. package/src/tasks/image-segmentation/data.ts +99 -0
  70. package/src/tasks/image-segmentation/inference.ts +69 -0
  71. package/src/tasks/image-segmentation/spec/input.json +45 -0
  72. package/src/tasks/image-segmentation/spec/output.json +26 -0
  73. package/src/tasks/image-text-to-text/about.md +76 -0
  74. package/src/tasks/image-text-to-text/data.ts +102 -0
  75. package/src/tasks/image-to-3d/about.md +62 -0
  76. package/src/tasks/image-to-3d/data.ts +75 -0
  77. package/src/tasks/image-to-image/about.md +129 -0
  78. package/src/tasks/image-to-image/data.ts +101 -0
  79. package/src/tasks/image-to-image/inference.ts +68 -0
  80. package/src/tasks/image-to-image/spec/input.json +55 -0
  81. package/src/tasks/image-to-image/spec/output.json +12 -0
  82. package/src/tasks/image-to-text/about.md +61 -0
  83. package/src/tasks/image-to-text/data.ts +82 -0
  84. package/src/tasks/image-to-text/inference.ts +143 -0
  85. package/src/tasks/image-to-text/spec/input.json +34 -0
  86. package/src/tasks/image-to-text/spec/output.json +14 -0
  87. package/src/tasks/index.ts +312 -0
  88. package/src/tasks/keypoint-detection/about.md +57 -0
  89. package/src/tasks/keypoint-detection/data.ts +50 -0
  90. package/src/tasks/mask-generation/about.md +65 -0
  91. package/src/tasks/mask-generation/data.ts +55 -0
  92. package/src/tasks/object-detection/about.md +37 -0
  93. package/src/tasks/object-detection/data.ts +86 -0
  94. package/src/tasks/object-detection/inference.ts +75 -0
  95. package/src/tasks/object-detection/spec/input.json +31 -0
  96. package/src/tasks/object-detection/spec/output.json +50 -0
  97. package/src/tasks/placeholder/about.md +15 -0
  98. package/src/tasks/placeholder/data.ts +21 -0
  99. package/src/tasks/placeholder/spec/input.json +35 -0
  100. package/src/tasks/placeholder/spec/output.json +17 -0
  101. package/src/tasks/question-answering/about.md +56 -0
  102. package/src/tasks/question-answering/data.ts +75 -0
  103. package/src/tasks/question-answering/inference.ts +99 -0
  104. package/src/tasks/question-answering/spec/input.json +67 -0
  105. package/src/tasks/question-answering/spec/output.json +29 -0
  106. package/src/tasks/reinforcement-learning/about.md +167 -0
  107. package/src/tasks/reinforcement-learning/data.ts +75 -0
  108. package/src/tasks/sentence-similarity/about.md +97 -0
  109. package/src/tasks/sentence-similarity/data.ts +101 -0
  110. package/src/tasks/sentence-similarity/inference.ts +32 -0
  111. package/src/tasks/sentence-similarity/spec/input.json +40 -0
  112. package/src/tasks/sentence-similarity/spec/output.json +12 -0
  113. package/src/tasks/summarization/about.md +58 -0
  114. package/src/tasks/summarization/data.ts +76 -0
  115. package/src/tasks/summarization/inference.ts +57 -0
  116. package/src/tasks/summarization/spec/input.json +42 -0
  117. package/src/tasks/summarization/spec/output.json +14 -0
  118. package/src/tasks/table-question-answering/about.md +43 -0
  119. package/src/tasks/table-question-answering/data.ts +59 -0
  120. package/src/tasks/table-question-answering/inference.ts +61 -0
  121. package/src/tasks/table-question-answering/spec/input.json +44 -0
  122. package/src/tasks/table-question-answering/spec/output.json +40 -0
  123. package/src/tasks/tabular-classification/about.md +65 -0
  124. package/src/tasks/tabular-classification/data.ts +68 -0
  125. package/src/tasks/tabular-regression/about.md +87 -0
  126. package/src/tasks/tabular-regression/data.ts +57 -0
  127. package/src/tasks/text-classification/about.md +173 -0
  128. package/src/tasks/text-classification/data.ts +103 -0
  129. package/src/tasks/text-classification/inference.ts +51 -0
  130. package/src/tasks/text-classification/spec/input.json +35 -0
  131. package/src/tasks/text-classification/spec/output.json +11 -0
  132. package/src/tasks/text-generation/about.md +154 -0
  133. package/src/tasks/text-generation/data.ts +114 -0
  134. package/src/tasks/text-generation/inference.ts +200 -0
  135. package/src/tasks/text-generation/spec/input.json +219 -0
  136. package/src/tasks/text-generation/spec/output.json +179 -0
  137. package/src/tasks/text-generation/spec/stream_output.json +103 -0
  138. package/src/tasks/text-to-3d/about.md +62 -0
  139. package/src/tasks/text-to-3d/data.ts +56 -0
  140. package/src/tasks/text-to-audio/inference.ts +143 -0
  141. package/src/tasks/text-to-audio/spec/input.json +31 -0
  142. package/src/tasks/text-to-audio/spec/output.json +17 -0
  143. package/src/tasks/text-to-image/about.md +96 -0
  144. package/src/tasks/text-to-image/data.ts +100 -0
  145. package/src/tasks/text-to-image/inference.ts +75 -0
  146. package/src/tasks/text-to-image/spec/input.json +63 -0
  147. package/src/tasks/text-to-image/spec/output.json +13 -0
  148. package/src/tasks/text-to-speech/about.md +63 -0
  149. package/src/tasks/text-to-speech/data.ts +79 -0
  150. package/src/tasks/text-to-speech/inference.ts +145 -0
  151. package/src/tasks/text-to-speech/spec/input.json +31 -0
  152. package/src/tasks/text-to-speech/spec/output.json +7 -0
  153. package/src/tasks/text-to-video/about.md +41 -0
  154. package/src/tasks/text-to-video/data.ts +102 -0
  155. package/src/tasks/text2text-generation/inference.ts +55 -0
  156. package/src/tasks/text2text-generation/spec/input.json +55 -0
  157. package/src/tasks/text2text-generation/spec/output.json +14 -0
  158. package/src/tasks/token-classification/about.md +76 -0
  159. package/src/tasks/token-classification/data.ts +92 -0
  160. package/src/tasks/token-classification/inference.ts +85 -0
  161. package/src/tasks/token-classification/spec/input.json +65 -0
  162. package/src/tasks/token-classification/spec/output.json +37 -0
  163. package/src/tasks/translation/about.md +65 -0
  164. package/src/tasks/translation/data.ts +70 -0
  165. package/src/tasks/translation/inference.ts +67 -0
  166. package/src/tasks/translation/spec/input.json +50 -0
  167. package/src/tasks/translation/spec/output.json +14 -0
  168. package/src/tasks/unconditional-image-generation/about.md +50 -0
  169. package/src/tasks/unconditional-image-generation/data.ts +72 -0
  170. package/src/tasks/video-classification/about.md +37 -0
  171. package/src/tasks/video-classification/data.ts +84 -0
  172. package/src/tasks/video-classification/inference.ts +59 -0
  173. package/src/tasks/video-classification/spec/input.json +42 -0
  174. package/src/tasks/video-classification/spec/output.json +10 -0
  175. package/src/tasks/video-text-to-text/about.md +98 -0
  176. package/src/tasks/video-text-to-text/data.ts +66 -0
  177. package/src/tasks/visual-question-answering/about.md +48 -0
  178. package/src/tasks/visual-question-answering/data.ts +97 -0
  179. package/src/tasks/visual-question-answering/inference.ts +62 -0
  180. package/src/tasks/visual-question-answering/spec/input.json +41 -0
  181. package/src/tasks/visual-question-answering/spec/output.json +21 -0
  182. package/src/tasks/zero-shot-classification/about.md +40 -0
  183. package/src/tasks/zero-shot-classification/data.ts +70 -0
  184. package/src/tasks/zero-shot-classification/inference.ts +67 -0
  185. package/src/tasks/zero-shot-classification/spec/input.json +50 -0
  186. package/src/tasks/zero-shot-classification/spec/output.json +11 -0
  187. package/src/tasks/zero-shot-image-classification/about.md +75 -0
  188. package/src/tasks/zero-shot-image-classification/data.ts +84 -0
  189. package/src/tasks/zero-shot-image-classification/inference.ts +61 -0
  190. package/src/tasks/zero-shot-image-classification/spec/input.json +45 -0
  191. package/src/tasks/zero-shot-image-classification/spec/output.json +10 -0
  192. package/src/tasks/zero-shot-object-detection/about.md +45 -0
  193. package/src/tasks/zero-shot-object-detection/data.ts +67 -0
  194. package/src/tasks/zero-shot-object-detection/inference.ts +66 -0
  195. package/src/tasks/zero-shot-object-detection/spec/input.json +40 -0
  196. package/src/tasks/zero-shot-object-detection/spec/output.json +47 -0
  197. package/src/tokenizer-data.ts +32 -0
  198. package/src/widget-example.ts +125 -0
@@ -0,0 +1,322 @@
1
+ /**
2
+ * Inference code generated from the JSON schema spec in ./spec
3
+ *
4
+ * Using src/scripts/inference-codegen
5
+ */
6
+
7
+ /**
8
+ * Chat Completion Input.
9
+ *
10
+ * Auto-generated from TGI specs.
11
+ * For more details, check out
12
+ * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
13
+ */
14
+ export interface ChatCompletionInput {
15
+ /**
16
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing
17
+ * frequency in the text so far,
18
+ * decreasing the model's likelihood to repeat the same line verbatim.
19
+ */
20
+ frequency_penalty?: number;
21
+ /**
22
+ * UNUSED
23
+ * Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON
24
+ * object that maps tokens
25
+ * (specified by their token ID in the tokenizer) to an associated bias value from -100 to
26
+ * 100. Mathematically,
27
+ * the bias is added to the logits generated by the model prior to sampling. The exact
28
+ * effect will vary per model,
29
+ * but values between -1 and 1 should decrease or increase likelihood of selection; values
30
+ * like -100 or 100 should
31
+ * result in a ban or exclusive selection of the relevant token.
32
+ */
33
+ logit_bias?: number[];
34
+ /**
35
+ * Whether to return log probabilities of the output tokens or not. If true, returns the log
36
+ * probabilities of each
37
+ * output token returned in the content of message.
38
+ */
39
+ logprobs?: boolean;
40
+ /**
41
+ * The maximum number of tokens that can be generated in the chat completion.
42
+ */
43
+ max_tokens?: number;
44
+ /**
45
+ * A list of messages comprising the conversation so far.
46
+ */
47
+ messages: ChatCompletionInputMessage[];
48
+ /**
49
+ * [UNUSED] ID of the model to use. See the model endpoint compatibility table for details
50
+ * on which models work with the Chat API.
51
+ */
52
+ model?: string;
53
+ /**
54
+ * UNUSED
55
+ * How many chat completion choices to generate for each input message. Note that you will
56
+ * be charged based on the
57
+ * number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
58
+ */
59
+ n?: number;
60
+ /**
61
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they
62
+ * appear in the text so far,
63
+ * increasing the model's likelihood to talk about new topics
64
+ */
65
+ presence_penalty?: number;
66
+ response_format?: ChatCompletionInputGrammarType;
67
+ seed?: number;
68
+ /**
69
+ * Up to 4 sequences where the API will stop generating further tokens.
70
+ */
71
+ stop?: string[];
72
+ stream?: boolean;
73
+ stream_options?: ChatCompletionInputStreamOptions;
74
+ /**
75
+ * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the
76
+ * output more random, while
77
+ * lower values like 0.2 will make it more focused and deterministic.
78
+ *
79
+ * We generally recommend altering this or `top_p` but not both.
80
+ */
81
+ temperature?: number;
82
+ tool_choice?: ChatCompletionInputTool;
83
+ /**
84
+ * A prompt to be appended before the tools
85
+ */
86
+ tool_prompt?: string;
87
+ /**
88
+ * A list of tools the model may call. Currently, only functions are supported as a tool.
89
+ * Use this to provide a list of
90
+ * functions the model may generate JSON inputs for.
91
+ */
92
+ tools?: ToolElement[];
93
+ /**
94
+ * An integer between 0 and 5 specifying the number of most likely tokens to return at each
95
+ * token position, each with
96
+ * an associated log probability. logprobs must be set to true if this parameter is used.
97
+ */
98
+ top_logprobs?: number;
99
+ /**
100
+ * An alternative to sampling with temperature, called nucleus sampling, where the model
101
+ * considers the results of the
102
+ * tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10%
103
+ * probability mass are considered.
104
+ */
105
+ top_p?: number;
106
+ [property: string]: unknown;
107
+ }
108
+
109
+ export interface ChatCompletionInputMessage {
110
+ content: ChatCompletionInputMessageContent;
111
+ name?: string;
112
+ role: string;
113
+ [property: string]: unknown;
114
+ }
115
+
116
+ export type ChatCompletionInputMessageContent = ChatCompletionInputMessageChunk[] | string;
117
+
118
+ export interface ChatCompletionInputMessageChunk {
119
+ image_url?: ChatCompletionInputURL;
120
+ text?: string;
121
+ type: ChatCompletionInputMessageChunkType;
122
+ [property: string]: unknown;
123
+ }
124
+
125
+ export interface ChatCompletionInputURL {
126
+ url: string;
127
+ [property: string]: unknown;
128
+ }
129
+
130
+ export type ChatCompletionInputMessageChunkType = "text" | "image_url";
131
+
132
+ export interface ChatCompletionInputGrammarType {
133
+ type: ChatCompletionInputGrammarTypeType;
134
+ /**
135
+ * A string that represents a [JSON Schema](https://json-schema.org/).
136
+ *
137
+ * JSON Schema is a declarative language that allows to annotate JSON documents
138
+ * with types and descriptions.
139
+ */
140
+ value: unknown;
141
+ [property: string]: unknown;
142
+ }
143
+
144
+ export type ChatCompletionInputGrammarTypeType = "json" | "regex";
145
+
146
+ export interface ChatCompletionInputStreamOptions {
147
+ /**
148
+ * If set, an additional chunk will be streamed before the data: [DONE] message. The usage
149
+ * field on this chunk shows the token usage statistics for the entire request, and the
150
+ * choices field will always be an empty array. All other chunks will also include a usage
151
+ * field, but with a null value.
152
+ */
153
+ include_usage: boolean;
154
+ [property: string]: unknown;
155
+ }
156
+
157
+ export type ChatCompletionInputTool = ChatCompletionInputToolType | string;
158
+
159
+ export interface ChatCompletionInputToolType {
160
+ function?: ChatCompletionInputFunctionName;
161
+ [property: string]: unknown;
162
+ }
163
+
164
+ export interface ChatCompletionInputFunctionName {
165
+ name: string;
166
+ [property: string]: unknown;
167
+ }
168
+
169
+ export interface ToolElement {
170
+ function: ChatCompletionInputFunctionDefinition;
171
+ type: string;
172
+ [property: string]: unknown;
173
+ }
174
+
175
+ export interface ChatCompletionInputFunctionDefinition {
176
+ arguments: unknown;
177
+ description?: string;
178
+ name: string;
179
+ [property: string]: unknown;
180
+ }
181
+
182
+ /**
183
+ * Chat Completion Output.
184
+ *
185
+ * Auto-generated from TGI specs.
186
+ * For more details, check out
187
+ * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
188
+ */
189
+ export interface ChatCompletionOutput {
190
+ choices: ChatCompletionOutputComplete[];
191
+ created: number;
192
+ id: string;
193
+ model: string;
194
+ system_fingerprint: string;
195
+ usage: ChatCompletionOutputUsage;
196
+ [property: string]: unknown;
197
+ }
198
+
199
+ export interface ChatCompletionOutputComplete {
200
+ finish_reason: string;
201
+ index: number;
202
+ logprobs?: ChatCompletionOutputLogprobs;
203
+ message: ChatCompletionOutputMessage;
204
+ [property: string]: unknown;
205
+ }
206
+
207
+ export interface ChatCompletionOutputLogprobs {
208
+ content: ChatCompletionOutputLogprob[];
209
+ [property: string]: unknown;
210
+ }
211
+
212
+ export interface ChatCompletionOutputLogprob {
213
+ logprob: number;
214
+ token: string;
215
+ top_logprobs: ChatCompletionOutputTopLogprob[];
216
+ [property: string]: unknown;
217
+ }
218
+
219
+ export interface ChatCompletionOutputTopLogprob {
220
+ logprob: number;
221
+ token: string;
222
+ [property: string]: unknown;
223
+ }
224
+
225
+ export interface ChatCompletionOutputMessage {
226
+ content?: string;
227
+ role: string;
228
+ tool_calls?: ChatCompletionOutputToolCall[];
229
+ [property: string]: unknown;
230
+ }
231
+
232
+ export interface ChatCompletionOutputToolCall {
233
+ function: ChatCompletionOutputFunctionDefinition;
234
+ id: string;
235
+ type: string;
236
+ [property: string]: unknown;
237
+ }
238
+
239
+ export interface ChatCompletionOutputFunctionDefinition {
240
+ arguments: unknown;
241
+ description?: string;
242
+ name: string;
243
+ [property: string]: unknown;
244
+ }
245
+
246
+ export interface ChatCompletionOutputUsage {
247
+ completion_tokens: number;
248
+ prompt_tokens: number;
249
+ total_tokens: number;
250
+ [property: string]: unknown;
251
+ }
252
+
253
+ /**
254
+ * Chat Completion Stream Output.
255
+ *
256
+ * Auto-generated from TGI specs.
257
+ * For more details, check out
258
+ * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
259
+ */
260
+ export interface ChatCompletionStreamOutput {
261
+ choices: ChatCompletionStreamOutputChoice[];
262
+ created: number;
263
+ id: string;
264
+ model: string;
265
+ system_fingerprint: string;
266
+ usage?: ChatCompletionStreamOutputUsage;
267
+ [property: string]: unknown;
268
+ }
269
+
270
+ export interface ChatCompletionStreamOutputChoice {
271
+ delta: ChatCompletionStreamOutputDelta;
272
+ finish_reason?: string;
273
+ index: number;
274
+ logprobs?: ChatCompletionStreamOutputLogprobs;
275
+ [property: string]: unknown;
276
+ }
277
+
278
+ export interface ChatCompletionStreamOutputDelta {
279
+ content?: string;
280
+ role: string;
281
+ tool_calls?: ChatCompletionStreamOutputDeltaToolCall;
282
+ [property: string]: unknown;
283
+ }
284
+
285
+ export interface ChatCompletionStreamOutputDeltaToolCall {
286
+ function: ChatCompletionStreamOutputFunction;
287
+ id: string;
288
+ index: number;
289
+ type: string;
290
+ [property: string]: unknown;
291
+ }
292
+
293
+ export interface ChatCompletionStreamOutputFunction {
294
+ arguments: string;
295
+ name?: string;
296
+ [property: string]: unknown;
297
+ }
298
+
299
+ export interface ChatCompletionStreamOutputLogprobs {
300
+ content: ChatCompletionStreamOutputLogprob[];
301
+ [property: string]: unknown;
302
+ }
303
+
304
+ export interface ChatCompletionStreamOutputLogprob {
305
+ logprob: number;
306
+ token: string;
307
+ top_logprobs: ChatCompletionStreamOutputTopLogprob[];
308
+ [property: string]: unknown;
309
+ }
310
+
311
+ export interface ChatCompletionStreamOutputTopLogprob {
312
+ logprob: number;
313
+ token: string;
314
+ [property: string]: unknown;
315
+ }
316
+
317
+ export interface ChatCompletionStreamOutputUsage {
318
+ completion_tokens: number;
319
+ prompt_tokens: number;
320
+ total_tokens: number;
321
+ [property: string]: unknown;
322
+ }
@@ -0,0 +1,350 @@
1
+ {
2
+ "$id": "/inference/schemas/chat-completion/input.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Chat Completion Input.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.",
5
+ "title": "ChatCompletionInput",
6
+ "type": "object",
7
+ "required": ["messages"],
8
+ "properties": {
9
+ "frequency_penalty": {
10
+ "type": "number",
11
+ "format": "float",
12
+ "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far,\ndecreasing the model's likelihood to repeat the same line verbatim.",
13
+ "example": "1.0",
14
+ "nullable": true
15
+ },
16
+ "logit_bias": {
17
+ "type": "array",
18
+ "items": {
19
+ "type": "number",
20
+ "format": "float"
21
+ },
22
+ "description": "UNUSED\nModify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens\n(specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically,\nthe bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model,\nbut values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should\nresult in a ban or exclusive selection of the relevant token.",
23
+ "nullable": true
24
+ },
25
+ "logprobs": {
26
+ "type": "boolean",
27
+ "description": "Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each\noutput token returned in the content of message.",
28
+ "example": "false",
29
+ "nullable": true
30
+ },
31
+ "max_tokens": {
32
+ "type": "integer",
33
+ "format": "int32",
34
+ "description": "The maximum number of tokens that can be generated in the chat completion.",
35
+ "example": "32",
36
+ "nullable": true,
37
+ "minimum": 0
38
+ },
39
+ "messages": {
40
+ "type": "array",
41
+ "items": {
42
+ "$ref": "#/$defs/ChatCompletionInputMessage"
43
+ },
44
+ "description": "A list of messages comprising the conversation so far.",
45
+ "example": "[{\"role\": \"user\", \"content\": \"What is Deep Learning?\"}]"
46
+ },
47
+ "model": {
48
+ "type": "string",
49
+ "description": "[UNUSED] ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.",
50
+ "example": "mistralai/Mistral-7B-Instruct-v0.2",
51
+ "nullable": true
52
+ },
53
+ "n": {
54
+ "type": "integer",
55
+ "format": "int32",
56
+ "description": "UNUSED\nHow many chat completion choices to generate for each input message. Note that you will be charged based on the\nnumber of generated tokens across all of the choices. Keep n as 1 to minimize costs.",
57
+ "example": "2",
58
+ "nullable": true,
59
+ "minimum": 0
60
+ },
61
+ "presence_penalty": {
62
+ "type": "number",
63
+ "format": "float",
64
+ "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far,\nincreasing the model's likelihood to talk about new topics",
65
+ "example": 0.1,
66
+ "nullable": true
67
+ },
68
+ "response_format": {
69
+ "allOf": [
70
+ {
71
+ "$ref": "#/$defs/ChatCompletionInputGrammarType"
72
+ }
73
+ ],
74
+ "default": "null",
75
+ "nullable": true
76
+ },
77
+ "seed": {
78
+ "type": "integer",
79
+ "format": "int64",
80
+ "example": 42,
81
+ "nullable": true,
82
+ "minimum": 0
83
+ },
84
+ "stop": {
85
+ "type": "array",
86
+ "items": {
87
+ "type": "string"
88
+ },
89
+ "description": "Up to 4 sequences where the API will stop generating further tokens.",
90
+ "example": "null",
91
+ "nullable": true
92
+ },
93
+ "stream": {
94
+ "type": "boolean"
95
+ },
96
+ "stream_options": {
97
+ "allOf": [
98
+ {
99
+ "$ref": "#/$defs/ChatCompletionInputStreamOptions"
100
+ }
101
+ ],
102
+ "nullable": true
103
+ },
104
+ "temperature": {
105
+ "type": "number",
106
+ "format": "float",
107
+ "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while\nlower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.",
108
+ "example": 1,
109
+ "nullable": true
110
+ },
111
+ "tool_choice": {
112
+ "allOf": [
113
+ {
114
+ "$ref": "#/$defs/ChatCompletionInputToolChoice"
115
+ }
116
+ ],
117
+ "nullable": true
118
+ },
119
+ "tool_prompt": {
120
+ "type": "string",
121
+ "description": "A prompt to be appended before the tools",
122
+ "example": "Given the functions available, please respond with a JSON for a function call with its proper arguments that best answers the given prompt. Respond in the format {name: function name, parameters: dictionary of argument name and its value}.Do not use variables.",
123
+ "nullable": true
124
+ },
125
+ "tools": {
126
+ "type": "array",
127
+ "items": {
128
+ "$ref": "#/$defs/ChatCompletionInputTool"
129
+ },
130
+ "description": "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of\nfunctions the model may generate JSON inputs for.",
131
+ "example": "null",
132
+ "nullable": true
133
+ },
134
+ "top_logprobs": {
135
+ "type": "integer",
136
+ "format": "int32",
137
+ "description": "An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with\nan associated log probability. logprobs must be set to true if this parameter is used.",
138
+ "example": "5",
139
+ "nullable": true,
140
+ "minimum": 0
141
+ },
142
+ "top_p": {
143
+ "type": "number",
144
+ "format": "float",
145
+ "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the\ntokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.",
146
+ "example": 0.95,
147
+ "nullable": true
148
+ }
149
+ },
150
+ "$defs": {
151
+ "ChatCompletionInputMessage": {
152
+ "type": "object",
153
+ "required": ["role", "content"],
154
+ "properties": {
155
+ "content": {
156
+ "$ref": "#/$defs/ChatCompletionInputMessageContent"
157
+ },
158
+ "name": {
159
+ "type": "string",
160
+ "example": "\"David\"",
161
+ "nullable": true
162
+ },
163
+ "role": {
164
+ "type": "string",
165
+ "example": "user"
166
+ }
167
+ },
168
+ "title": "ChatCompletionInputMessage"
169
+ },
170
+ "ChatCompletionInputMessageContent": {
171
+ "oneOf": [
172
+ {
173
+ "type": "string"
174
+ },
175
+ {
176
+ "type": "array",
177
+ "items": {
178
+ "$ref": "#/$defs/ChatCompletionInputMessageChunk"
179
+ }
180
+ }
181
+ ],
182
+ "title": "ChatCompletionInputMessageContent"
183
+ },
184
+ "ChatCompletionInputMessageChunk": {
185
+ "oneOf": [
186
+ {
187
+ "type": "object",
188
+ "required": ["text", "type"],
189
+ "properties": {
190
+ "text": {
191
+ "type": "string"
192
+ },
193
+ "type": {
194
+ "type": "string",
195
+ "enum": ["text"]
196
+ }
197
+ }
198
+ },
199
+ {
200
+ "type": "object",
201
+ "required": ["image_url", "type"],
202
+ "properties": {
203
+ "image_url": {
204
+ "$ref": "#/$defs/ChatCompletionInputUrl"
205
+ },
206
+ "type": {
207
+ "type": "string",
208
+ "enum": ["image_url"]
209
+ }
210
+ }
211
+ }
212
+ ],
213
+ "discriminator": {
214
+ "propertyName": "type"
215
+ },
216
+ "title": "ChatCompletionInputMessageChunk"
217
+ },
218
+ "ChatCompletionInputUrl": {
219
+ "type": "object",
220
+ "required": ["url"],
221
+ "properties": {
222
+ "url": {
223
+ "type": "string"
224
+ }
225
+ },
226
+ "title": "ChatCompletionInputUrl"
227
+ },
228
+ "ChatCompletionInputGrammarType": {
229
+ "oneOf": [
230
+ {
231
+ "type": "object",
232
+ "required": ["type", "value"],
233
+ "properties": {
234
+ "type": {
235
+ "type": "string",
236
+ "enum": ["json"]
237
+ },
238
+ "value": {
239
+ "description": "A string that represents a [JSON Schema](https://json-schema.org/).\n\nJSON Schema is a declarative language that allows to annotate JSON documents\nwith types and descriptions."
240
+ }
241
+ }
242
+ },
243
+ {
244
+ "type": "object",
245
+ "required": ["type", "value"],
246
+ "properties": {
247
+ "type": {
248
+ "type": "string",
249
+ "enum": ["regex"]
250
+ },
251
+ "value": {
252
+ "type": "string"
253
+ }
254
+ }
255
+ }
256
+ ],
257
+ "discriminator": {
258
+ "propertyName": "type"
259
+ },
260
+ "title": "ChatCompletionInputGrammarType"
261
+ },
262
+ "ChatCompletionInputStreamOptions": {
263
+ "type": "object",
264
+ "required": ["include_usage"],
265
+ "properties": {
266
+ "include_usage": {
267
+ "type": "boolean",
268
+ "description": "If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value.",
269
+ "example": "true"
270
+ }
271
+ },
272
+ "title": "ChatCompletionInputStreamOptions"
273
+ },
274
+ "ChatCompletionInputToolChoice": {
275
+ "allOf": [
276
+ {
277
+ "$ref": "#/$defs/ChatCompletionInputToolType"
278
+ }
279
+ ],
280
+ "nullable": true,
281
+ "title": "ChatCompletionInputToolChoice"
282
+ },
283
+ "ChatCompletionInputToolType": {
284
+ "oneOf": [
285
+ {
286
+ "type": "object",
287
+ "default": null,
288
+ "nullable": true
289
+ },
290
+ {
291
+ "type": "string"
292
+ },
293
+ {
294
+ "type": "object",
295
+ "required": ["function"],
296
+ "properties": {
297
+ "function": {
298
+ "$ref": "#/$defs/ChatCompletionInputFunctionName"
299
+ }
300
+ }
301
+ },
302
+ {
303
+ "type": "object",
304
+ "default": null,
305
+ "nullable": true
306
+ }
307
+ ],
308
+ "title": "ChatCompletionInputToolType"
309
+ },
310
+ "ChatCompletionInputFunctionName": {
311
+ "type": "object",
312
+ "required": ["name"],
313
+ "properties": {
314
+ "name": {
315
+ "type": "string"
316
+ }
317
+ },
318
+ "title": "ChatCompletionInputFunctionName"
319
+ },
320
+ "ChatCompletionInputTool": {
321
+ "type": "object",
322
+ "required": ["type", "function"],
323
+ "properties": {
324
+ "function": {
325
+ "$ref": "#/$defs/ChatCompletionInputFunctionDefinition"
326
+ },
327
+ "type": {
328
+ "type": "string",
329
+ "example": "function"
330
+ }
331
+ },
332
+ "title": "ChatCompletionInputTool"
333
+ },
334
+ "ChatCompletionInputFunctionDefinition": {
335
+ "type": "object",
336
+ "required": ["name", "arguments"],
337
+ "properties": {
338
+ "arguments": {},
339
+ "description": {
340
+ "type": "string",
341
+ "nullable": true
342
+ },
343
+ "name": {
344
+ "type": "string"
345
+ }
346
+ },
347
+ "title": "ChatCompletionInputFunctionDefinition"
348
+ }
349
+ }
350
+ }