Commit 4872048
committed
fix: unify OpenAI-compatible provider response parsing with GPT-5.1 format
Updated OpenAI-compatible provider to use the same nested response structure
as the OpenAI GPT-5.1 provider for consistency and compatibility.
Response Structure Changes:
- Changed ResponseAPIResponse to match GPT-5.1 format
- `type` → `object` field
- Nested output: output[{type: "message", content: [{type: "output_text", text: "..."}]}]
- Updated token fields: input_tokens/output_tokens
Content Extraction:
- Updated generate_chat() to extract text from nested structure
- Filter for "message" type items → "output_text" type content
- Join multiple content items with newlines
Chat Completions Fallback:
- Convert Chat Completions response to unified output array structure
- Create proper nested ResponseOutputItem with ResponseOutputContent
- Ensures consistent parsing regardless of API endpoint used
Tests Updated:
- Fixed test assertions for use_responses_api (now false for Ollama/LM Studio)
- Added comments explaining API choice
This ensures all providers (OpenAI GPT-5.1, Ollama, LM Studio, custom endpoints)
use the same response parsing logic, reducing code duplication and bugs.1 parent fc432a9 commit 4872048
1 file changed
+42
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
304 | 313 | | |
305 | 314 | | |
306 | | - | |
| 315 | + | |
307 | 316 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
312 | 320 | | |
313 | 321 | | |
314 | | - | |
315 | 322 | | |
316 | 323 | | |
317 | 324 | | |
| |||
326 | 333 | | |
327 | 334 | | |
328 | 335 | | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
340 | 347 | | |
341 | 348 | | |
342 | 349 | | |
343 | 350 | | |
344 | | - | |
| 351 | + | |
345 | 352 | | |
346 | 353 | | |
347 | 354 | | |
| |||
469 | 476 | | |
470 | 477 | | |
471 | 478 | | |
472 | | - | |
473 | | - | |
| 479 | + | |
474 | 480 | | |
475 | 481 | | |
476 | 482 | | |
477 | | - | |
478 | | - | |
479 | | - | |
| 483 | + | |
480 | 484 | | |
481 | | - | |
| 485 | + | |
482 | 486 | | |
483 | 487 | | |
484 | 488 | | |
485 | | - | |
| 489 | + | |
486 | 490 | | |
487 | 491 | | |
488 | 492 | | |
489 | | - | |
| 493 | + | |
490 | 494 | | |
491 | 495 | | |
492 | 496 | | |
493 | | - | |
494 | | - | |
495 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
496 | 507 | | |
497 | 508 | | |
498 | | - | |
499 | | - | |
500 | 509 | | |
501 | 510 | | |
502 | 511 | | |
| |||
553 | 562 | | |
554 | 563 | | |
555 | 564 | | |
556 | | - | |
| 565 | + | |
557 | 566 | | |
558 | 567 | | |
559 | 568 | | |
560 | 569 | | |
561 | 570 | | |
562 | 571 | | |
563 | 572 | | |
564 | | - | |
| 573 | + | |
565 | 574 | | |
566 | 575 | | |
0 commit comments