Commit 4c82211
authored
Update chat-completion json_schema specs (JS) (#1537)
In huggingface/huggingface_hub#3082
@hanouticelina fixed the Python inference types for chat completion
grammar input. Biggest update was:
```py
@dataclass_with_extra
class ChatCompletionInputResponseFormatText(BaseInferenceType):
type: Literal["text"]
@dataclass_with_extra
class ChatCompletionInputResponseFormatJSONSchema(BaseInferenceType):
type: Literal["json_schema"]
json_schema: ChatCompletionInputJSONSchema
@dataclass_with_extra
class ChatCompletionInputResponseFormatJSONObject(BaseInferenceType):
type: Literal["json_object"]
ChatCompletionInputGrammarType = Union[
ChatCompletionInputResponseFormatText,
ChatCompletionInputResponseFormatJSONSchema,
ChatCompletionInputResponseFormatJSONObject,
]
```
---
This PR reflects "officially" this update in the JS specs. It makes JS
and Python specs aligned again (was not the case for the last month,
ending up with annoying PRs like this one
huggingface/huggingface_hub#3104). The result is
not as satisfying as what a manual implementation would give because the
3 objects are merged in 1 with optional fields (see `export type
ChatCompletionInputGrammarTypeType = "text" | "json_schema" |
"json_object";`). This is because quicktype do not handle properly
unions (see glideapps/quicktype#1266 - 6 yo
:confused: ). It's not the only case like this in our specs but first
time I find out about it. Not a problem since we don't enforce data
structures.
In Python, the data structure will result in this:
huggingface/huggingface_hub#31671 parent 56e9f9d commit 4c82211
File tree
2 files changed
+77
-45
lines changed- packages/tasks/src/tasks/chat-completion
- spec
2 files changed
+77
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
139 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
140 | 144 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
145 | 163 | | |
146 | | - | |
| 164 | + | |
147 | 165 | | |
148 | 166 | | |
149 | | - | |
| 167 | + | |
150 | 168 | | |
151 | 169 | | |
152 | 170 | | |
| |||
Lines changed: 53 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 294 | + | |
305 | 295 | | |
306 | 296 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 297 | + | |
318 | 298 | | |
319 | 299 | | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
| 300 | + | |
331 | 301 | | |
332 | 302 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | 303 | | |
337 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
338 | 341 | | |
339 | 342 | | |
340 | | - | |
| 343 | + | |
341 | 344 | | |
342 | 345 | | |
343 | 346 | | |
344 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
345 | 352 | | |
346 | 353 | | |
347 | 354 | | |
348 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
349 | 363 | | |
350 | 364 | | |
351 | 365 | | |
| |||
0 commit comments