@huggingface/tasks 0.12.7 → 0.12.9

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 (32) hide show
  1. package/dist/index.cjs +58 -2
  2. package/dist/index.js +58 -2
  3. package/dist/src/model-libraries.d.ts +9 -2
  4. package/dist/src/model-libraries.d.ts.map +1 -1
  5. package/dist/src/tasks/automatic-speech-recognition/inference.d.ts +2 -2
  6. package/dist/src/tasks/chat-completion/inference.d.ts +58 -21
  7. package/dist/src/tasks/chat-completion/inference.d.ts.map +1 -1
  8. package/dist/src/tasks/image-to-text/inference.d.ts +2 -2
  9. package/dist/src/tasks/index.d.ts +1 -1
  10. package/dist/src/tasks/index.d.ts.map +1 -1
  11. package/dist/src/tasks/text-generation/inference.d.ts +62 -0
  12. package/dist/src/tasks/text-generation/inference.d.ts.map +1 -1
  13. package/dist/src/tasks/text-to-audio/inference.d.ts +2 -2
  14. package/dist/src/tasks/text-to-speech/inference.d.ts +6 -8
  15. package/dist/src/tasks/text-to-speech/inference.d.ts.map +1 -1
  16. package/package.json +1 -1
  17. package/src/model-libraries-snippets.ts +1 -1
  18. package/src/model-libraries.ts +7 -0
  19. package/src/tasks/automatic-speech-recognition/inference.ts +2 -2
  20. package/src/tasks/chat-completion/inference.ts +66 -21
  21. package/src/tasks/chat-completion/spec/input.json +163 -40
  22. package/src/tasks/chat-completion/spec/output.json +28 -18
  23. package/src/tasks/chat-completion/spec/stream_output.json +57 -14
  24. package/src/tasks/common-definitions.json +2 -2
  25. package/src/tasks/image-to-text/inference.ts +2 -2
  26. package/src/tasks/index.ts +3 -2
  27. package/src/tasks/text-generation/inference.ts +62 -0
  28. package/src/tasks/text-generation/spec/input.json +24 -0
  29. package/src/tasks/text-generation/spec/stream_output.json +7 -1
  30. package/src/tasks/text-to-audio/inference.ts +2 -2
  31. package/src/tasks/text-to-speech/inference.ts +6 -8
  32. package/src/tasks/text-to-speech/spec/input.json +26 -2
@@ -1 +1 @@
1
- {"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-speech/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
1
+ {"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-speech/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
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.12.7",
4
+ "version": "0.12.9",
5
5
  "description": "List of ML tasks for huggingface.co/tasks",
6
6
  "repository": "https://github.com/huggingface/huggingface.js.git",
7
7
  "publishConfig": {
@@ -9,7 +9,7 @@ function nameWithoutNamespace(modelId: string): string {
9
9
  return splitted.length === 1 ? splitted[0] : splitted[1];
10
10
  }
11
11
 
12
- const escapeStringForJson = (str: string): string => JSON.stringify(str);
12
+ const escapeStringForJson = (str: string): string => JSON.stringify(str).slice(1, -1); // slice is needed to remove surrounding quotes added by JSON.stringify
13
13
 
14
14
  //#region snippets
15
15
 
@@ -406,6 +406,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
406
406
  filter: false,
407
407
  countDownloads: `path:"mlc-chat-config.json"`,
408
408
  },
409
+ moshi: {
410
+ prettyLabel: "Moshi",
411
+ repoName: "Moshi",
412
+ repoUrl: "https://github.com/kyutai-labs/moshi",
413
+ filter: false,
414
+ countDownloads: `path:"tokenizer-e351c8d8-checkpoint125.safetensors"`,
415
+ },
409
416
  nemo: {
410
417
  prettyLabel: "NeMo",
411
418
  repoName: "NeMo",
@@ -73,7 +73,7 @@ export interface GenerationParameters {
73
73
  */
74
74
  max_length?: number;
75
75
  /**
76
- * The maximum number of tokens to generate. Takes precedence over maxLength.
76
+ * The maximum number of tokens to generate. Takes precedence over max_length.
77
77
  */
78
78
  max_new_tokens?: number;
79
79
  /**
@@ -81,7 +81,7 @@ export interface GenerationParameters {
81
81
  */
82
82
  min_length?: number;
83
83
  /**
84
- * The minimum number of tokens to generate. Takes precedence over maxLength.
84
+ * The minimum number of tokens to generate. Takes precedence over min_length.
85
85
  */
86
86
  min_new_tokens?: number;
87
87
  /**
@@ -49,7 +49,7 @@ export interface ChatCompletionInput {
49
49
  * [UNUSED] ID of the model to use. See the model endpoint compatibility table for details
50
50
  * on which models work with the Chat API.
51
51
  */
52
- model: string;
52
+ model?: string;
53
53
  /**
54
54
  * UNUSED
55
55
  * How many chat completion choices to generate for each input message. Note that you will
@@ -63,12 +63,14 @@ export interface ChatCompletionInput {
63
63
  * increasing the model's likelihood to talk about new topics
64
64
  */
65
65
  presence_penalty?: number;
66
+ response_format?: ChatCompletionInputGrammarType;
66
67
  seed?: number;
67
68
  /**
68
69
  * Up to 4 sequences where the API will stop generating further tokens.
69
70
  */
70
71
  stop?: string[];
71
72
  stream?: boolean;
73
+ stream_options?: ChatCompletionInputStreamOptions;
72
74
  /**
73
75
  * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the
74
76
  * output more random, while
@@ -77,7 +79,7 @@ export interface ChatCompletionInput {
77
79
  * We generally recommend altering this or `top_p` but not both.
78
80
  */
79
81
  temperature?: number;
80
- tool_choice?: ChatCompletionInputToolType;
82
+ tool_choice?: ChatCompletionInputTool;
81
83
  /**
82
84
  * A prompt to be appended before the tools
83
85
  */
@@ -87,7 +89,7 @@ export interface ChatCompletionInput {
87
89
  * Use this to provide a list of
88
90
  * functions the model may generate JSON inputs for.
89
91
  */
90
- tools?: ChatCompletionInputTool[];
92
+ tools?: ToolElement[];
91
93
  /**
92
94
  * An integer between 0 and 5 specifying the number of most likely tokens to return at each
93
95
  * token position, each with
@@ -105,40 +107,78 @@ export interface ChatCompletionInput {
105
107
  }
106
108
 
107
109
  export interface ChatCompletionInputMessage {
108
- content?: string;
110
+ content: ChatCompletionInputMessageContent;
109
111
  name?: string;
110
112
  role: string;
111
- tool_calls?: ChatCompletionInputToolCall[];
112
113
  [property: string]: unknown;
113
114
  }
114
115
 
115
- export interface ChatCompletionInputToolCall {
116
- function: ChatCompletionInputFunctionDefinition;
117
- id: number;
118
- type: string;
116
+ export type ChatCompletionInputMessageContent = ChatCompletionInputMessageChunk[] | string;
117
+
118
+ export interface ChatCompletionInputMessageChunk {
119
+ image_url?: ChatCompletionInputURL;
120
+ text?: string;
121
+ type: ChatCompletionInputMessageChunkType;
119
122
  [property: string]: unknown;
120
123
  }
121
124
 
122
- export interface ChatCompletionInputFunctionDefinition {
123
- arguments: unknown;
124
- description?: string;
125
- name: string;
125
+ export interface ChatCompletionInputURL {
126
+ url: string;
126
127
  [property: string]: unknown;
127
128
  }
128
129
 
129
- export type ChatCompletionInputToolType = "OneOf" | ChatCompletionInputToolTypeObject;
130
+ export type ChatCompletionInputMessageChunkType = "text" | "image_url";
130
131
 
131
- export interface ChatCompletionInputToolTypeObject {
132
- FunctionName: string;
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;
133
154
  [property: string]: unknown;
134
155
  }
135
156
 
136
- export interface ChatCompletionInputTool {
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 {
137
170
  function: ChatCompletionInputFunctionDefinition;
138
171
  type: string;
139
172
  [property: string]: unknown;
140
173
  }
141
174
 
175
+ export interface ChatCompletionInputFunctionDefinition {
176
+ arguments: unknown;
177
+ description?: string;
178
+ name: string;
179
+ [property: string]: unknown;
180
+ }
181
+
142
182
  /**
143
183
  * Chat Completion Output.
144
184
  *
@@ -151,7 +191,6 @@ export interface ChatCompletionOutput {
151
191
  created: number;
152
192
  id: string;
153
193
  model: string;
154
- object: string;
155
194
  system_fingerprint: string;
156
195
  usage: ChatCompletionOutputUsage;
157
196
  [property: string]: unknown;
@@ -185,7 +224,6 @@ export interface ChatCompletionOutputTopLogprob {
185
224
 
186
225
  export interface ChatCompletionOutputMessage {
187
226
  content?: string;
188
- name?: string;
189
227
  role: string;
190
228
  tool_calls?: ChatCompletionOutputToolCall[];
191
229
  [property: string]: unknown;
@@ -193,7 +231,7 @@ export interface ChatCompletionOutputMessage {
193
231
 
194
232
  export interface ChatCompletionOutputToolCall {
195
233
  function: ChatCompletionOutputFunctionDefinition;
196
- id: number;
234
+ id: string;
197
235
  type: string;
198
236
  [property: string]: unknown;
199
237
  }
@@ -224,8 +262,8 @@ export interface ChatCompletionStreamOutput {
224
262
  created: number;
225
263
  id: string;
226
264
  model: string;
227
- object: string;
228
265
  system_fingerprint: string;
266
+ usage?: ChatCompletionStreamOutputUsage;
229
267
  [property: string]: unknown;
230
268
  }
231
269
 
@@ -275,3 +313,10 @@ export interface ChatCompletionStreamOutputTopLogprob {
275
313
  token: string;
276
314
  [property: string]: unknown;
277
315
  }
316
+
317
+ export interface ChatCompletionStreamOutputUsage {
318
+ completion_tokens: number;
319
+ prompt_tokens: number;
320
+ total_tokens: number;
321
+ [property: string]: unknown;
322
+ }
@@ -4,7 +4,7 @@
4
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
5
  "title": "ChatCompletionInput",
6
6
  "type": "object",
7
- "required": ["model", "messages"],
7
+ "required": ["messages"],
8
8
  "properties": {
9
9
  "frequency_penalty": {
10
10
  "type": "number",
@@ -47,7 +47,8 @@
47
47
  "model": {
48
48
  "type": "string",
49
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"
50
+ "example": "mistralai/Mistral-7B-Instruct-v0.2",
51
+ "nullable": true
51
52
  },
52
53
  "n": {
53
54
  "type": "integer",
@@ -64,6 +65,15 @@
64
65
  "example": 0.1,
65
66
  "nullable": true
66
67
  },
68
+ "response_format": {
69
+ "allOf": [
70
+ {
71
+ "$ref": "#/$defs/ChatCompletionInputGrammarType"
72
+ }
73
+ ],
74
+ "default": "null",
75
+ "nullable": true
76
+ },
67
77
  "seed": {
68
78
  "type": "integer",
69
79
  "format": "int64",
@@ -83,6 +93,14 @@
83
93
  "stream": {
84
94
  "type": "boolean"
85
95
  },
96
+ "stream_options": {
97
+ "allOf": [
98
+ {
99
+ "$ref": "#/$defs/ChatCompletionInputStreamOptions"
100
+ }
101
+ ],
102
+ "nullable": true
103
+ },
86
104
  "temperature": {
87
105
  "type": "number",
88
106
  "format": "float",
@@ -93,7 +111,7 @@
93
111
  "tool_choice": {
94
112
  "allOf": [
95
113
  {
96
- "$ref": "#/$defs/ChatCompletionInputToolType"
114
+ "$ref": "#/$defs/ChatCompletionInputToolChoice"
97
115
  }
98
116
  ],
99
117
  "nullable": true
@@ -101,7 +119,7 @@
101
119
  "tool_prompt": {
102
120
  "type": "string",
103
121
  "description": "A prompt to be appended before the tools",
104
- "example": "\"You will be presented with a JSON schema representing a set of tools.\nIf the user request lacks of sufficient information to make a precise tool selection: Do not invent any tool's properties, instead notify with an error message.\n\nJSON Schema:\n\"",
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.",
105
123
  "nullable": true
106
124
  },
107
125
  "tools": {
@@ -132,12 +150,10 @@
132
150
  "$defs": {
133
151
  "ChatCompletionInputMessage": {
134
152
  "type": "object",
135
- "required": ["role"],
153
+ "required": ["role", "content"],
136
154
  "properties": {
137
155
  "content": {
138
- "type": "string",
139
- "example": "My name is David and I",
140
- "nullable": true
156
+ "$ref": "#/$defs/ChatCompletionInputMessageContent"
141
157
  },
142
158
  "name": {
143
159
  "type": "string",
@@ -147,68 +163,160 @@
147
163
  "role": {
148
164
  "type": "string",
149
165
  "example": "user"
166
+ }
167
+ },
168
+ "title": "ChatCompletionInputMessage"
169
+ },
170
+ "ChatCompletionInputMessageContent": {
171
+ "oneOf": [
172
+ {
173
+ "type": "string"
150
174
  },
151
- "tool_calls": {
175
+ {
152
176
  "type": "array",
153
177
  "items": {
154
- "$ref": "#/$defs/ChatCompletionInputToolCall"
155
- },
156
- "nullable": true
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
+ }
157
211
  }
212
+ ],
213
+ "discriminator": {
214
+ "propertyName": "type"
158
215
  },
159
- "title": "ChatCompletionInputMessage"
216
+ "title": "ChatCompletionInputMessageChunk"
160
217
  },
161
- "ChatCompletionInputToolCall": {
218
+ "ChatCompletionInputUrl": {
162
219
  "type": "object",
163
- "required": ["id", "type", "function"],
220
+ "required": ["url"],
164
221
  "properties": {
165
- "function": {
166
- "$ref": "#/$defs/ChatCompletionInputFunctionDefinition"
167
- },
168
- "id": {
169
- "type": "integer",
170
- "format": "int32",
171
- "minimum": 0
172
- },
173
- "type": {
222
+ "url": {
174
223
  "type": "string"
175
224
  }
176
225
  },
177
- "title": "ChatCompletionInputToolCall"
226
+ "title": "ChatCompletionInputUrl"
178
227
  },
179
- "ChatCompletionInputFunctionDefinition": {
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": {
180
263
  "type": "object",
181
- "required": ["name", "arguments"],
264
+ "required": ["include_usage"],
182
265
  "properties": {
183
- "arguments": {},
184
- "description": {
185
- "type": "string",
186
- "nullable": true
187
- },
188
- "name": {
189
- "type": "string"
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"
190
270
  }
191
271
  },
192
- "title": "ChatCompletionInputFunctionDefinition"
272
+ "title": "ChatCompletionInputStreamOptions"
273
+ },
274
+ "ChatCompletionInputToolChoice": {
275
+ "allOf": [
276
+ {
277
+ "$ref": "#/$defs/ChatCompletionInputToolType"
278
+ }
279
+ ],
280
+ "nullable": true,
281
+ "title": "ChatCompletionInputToolChoice"
193
282
  },
194
283
  "ChatCompletionInputToolType": {
195
284
  "oneOf": [
196
285
  {
197
286
  "type": "object",
198
- "required": ["FunctionName"],
287
+ "default": null,
288
+ "nullable": true
289
+ },
290
+ {
291
+ "type": "string"
292
+ },
293
+ {
294
+ "type": "object",
295
+ "required": ["function"],
199
296
  "properties": {
200
- "FunctionName": {
201
- "type": "string"
297
+ "function": {
298
+ "$ref": "#/$defs/ChatCompletionInputFunctionName"
202
299
  }
203
300
  }
204
301
  },
205
302
  {
206
- "type": "string",
207
- "enum": ["OneOf"]
303
+ "type": "object",
304
+ "default": null,
305
+ "nullable": true
208
306
  }
209
307
  ],
210
308
  "title": "ChatCompletionInputToolType"
211
309
  },
310
+ "ChatCompletionInputFunctionName": {
311
+ "type": "object",
312
+ "required": ["name"],
313
+ "properties": {
314
+ "name": {
315
+ "type": "string"
316
+ }
317
+ },
318
+ "title": "ChatCompletionInputFunctionName"
319
+ },
212
320
  "ChatCompletionInputTool": {
213
321
  "type": "object",
214
322
  "required": ["type", "function"],
@@ -222,6 +330,21 @@
222
330
  }
223
331
  },
224
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"
225
348
  }
226
349
  }
227
350
  }
@@ -4,7 +4,7 @@
4
4
  "description": "Chat Completion Output.\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
5
  "title": "ChatCompletionOutput",
6
6
  "type": "object",
7
- "required": ["id", "object", "created", "model", "system_fingerprint", "choices", "usage"],
7
+ "required": ["id", "created", "model", "system_fingerprint", "choices", "usage"],
8
8
  "properties": {
9
9
  "choices": {
10
10
  "type": "array",
@@ -25,9 +25,6 @@
25
25
  "type": "string",
26
26
  "example": "mistralai/Mistral-7B-Instruct-v0.2"
27
27
  },
28
- "object": {
29
- "type": "string"
30
- },
31
28
  "system_fingerprint": {
32
29
  "type": "string"
33
30
  },
@@ -110,32 +107,47 @@
110
107
  "title": "ChatCompletionOutputTopLogprob"
111
108
  },
112
109
  "ChatCompletionOutputMessage": {
110
+ "oneOf": [
111
+ {
112
+ "$ref": "#/$defs/ChatCompletionOutputTextMessage"
113
+ },
114
+ {
115
+ "$ref": "#/$defs/ChatCompletionOutputToolCallMessage"
116
+ }
117
+ ],
118
+ "title": "ChatCompletionOutputMessage"
119
+ },
120
+ "ChatCompletionOutputTextMessage": {
113
121
  "type": "object",
114
- "required": ["role"],
122
+ "required": ["role", "content"],
115
123
  "properties": {
116
124
  "content": {
117
125
  "type": "string",
118
- "example": "My name is David and I",
119
- "nullable": true
120
- },
121
- "name": {
122
- "type": "string",
123
- "example": "\"David\"",
124
- "nullable": true
126
+ "example": "My name is David and I"
125
127
  },
126
128
  "role": {
127
129
  "type": "string",
128
130
  "example": "user"
131
+ }
132
+ },
133
+ "title": "ChatCompletionOutputTextMessage"
134
+ },
135
+ "ChatCompletionOutputToolCallMessage": {
136
+ "type": "object",
137
+ "required": ["role", "tool_calls"],
138
+ "properties": {
139
+ "role": {
140
+ "type": "string",
141
+ "example": "assistant"
129
142
  },
130
143
  "tool_calls": {
131
144
  "type": "array",
132
145
  "items": {
133
146
  "$ref": "#/$defs/ChatCompletionOutputToolCall"
134
- },
135
- "nullable": true
147
+ }
136
148
  }
137
149
  },
138
- "title": "ChatCompletionOutputMessage"
150
+ "title": "ChatCompletionOutputToolCallMessage"
139
151
  },
140
152
  "ChatCompletionOutputToolCall": {
141
153
  "type": "object",
@@ -145,9 +157,7 @@
145
157
  "$ref": "#/$defs/ChatCompletionOutputFunctionDefinition"
146
158
  },
147
159
  "id": {
148
- "type": "integer",
149
- "format": "int32",
150
- "minimum": 0
160
+ "type": "string"
151
161
  },
152
162
  "type": {
153
163
  "type": "string"