Commit 42366ff
committed
fix: align structured outputs API with vLLM's offline inference pattern
Previously, structured outputs support was incorrectly implemented by
extracting OpenAI-specific `extra_body.structured_outputs` from the
RunPod API's `sampling_params` dictionary. This mixed two different
API patterns:
1. The OpenAI API uses `extra_body` as a catch-all for vLLM-specific
parameters that aren't part of the OpenAI spec
2. The RunPod API uses `sampling_params` as a direct pass-through to
vLLM's `SamplingParams`, where all parameters should be at the same
level
The RunPod API should be a direct 1:1 mapping to vLLM's offline inference
API, not an abstraction layer. Previously, structured outputs support
incorrectly mixed OpenAI-specific patterns (`extra_body`) into the RunPod
API.
Changes:
- Remove OpenAI `extra_body` extraction from RunPod API path
- The OpenAI route already handles structured outputs correctly through
vLLM's OpenAI serving code
- RunPod API should only use `sampling_params` like all other parameters
- Simplify to direct extraction from `sampling_params.structured_outputs`
- Convert dict to `StructuredOutputsParams(**config)` directly
- Set on `SamplingParams` exactly as vLLM expects
- Update README to emphasize direct mapping to vLLM's API
The new implementation allows users to pass structured outputs exactly as
they would in vLLM's Python API:
```json
{
"sampling_params": {
"max_tokens": 128,
"structured_outputs": {
"json": {"type": "object", "properties": {...}},
"regex": "[A-Z]+",
"choice": ["Positive", "Negative"]
}
}
}
```
This directly maps to `SamplingParams(structured_outputs=StructuredOutputsParams(...))`
and maintains consistency with vLLM's documented offline inference patterns.
Users familiar with vLLM can use our API without learning new concepts.
When vLLM adds new structured output features, they automatically work
without code changes since we're just passing through the same parameters.1 parent c41f852 commit 42366ff
2 files changed
+42
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
| |||
416 | 417 | | |
417 | 418 | | |
418 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
419 | 449 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
74 | 64 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 65 | | |
95 | 66 | | |
96 | 67 | | |
| |||
0 commit comments