Commit Graph

4 Commits

Author SHA1 Message Date
Ishaan Jaffer e8461b5b97 style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
Chesars 0f20976efa fix(types): remove StreamingChoices from ModelResponse, use ModelResponseStream
ModelResponse.choices was typed as List[Union[Choices, StreamingChoices]] which
caused Pydantic serialization warnings and false linting errors. Now that
ModelResponseStream exists for streaming, narrow ModelResponse.choices to
List[Choices] and migrate all ModelResponse(stream=True) call sites to use
ModelResponseStream() instead.
2026-02-20 17:47:42 -03:00
Chesars 3564b8d83b fix(types): suppress Pydantic serialization warnings on ModelResponse choices
Pydantic v2's Union serializer for `List[Union[Choices, StreamingChoices]]`
tries both branches when serializing, emitting spurious
`PydanticSerializationUnexpectedValue` warnings (field count mismatch on
`Message` and type mismatch `Expected StreamingChoices but got Choices`).

Add a `WrapSerializer` on the `choices` field that serializes each item
individually via its own `model_dump()`, bypassing the Union dispatch
entirely while correctly propagating `exclude_none`, `exclude_unset`,
and `exclude_defaults` from the parent serialization context.
2026-02-19 21:43:19 -03:00
Matthias Humt 9adc19deab Normalize OpenAI SDK BaseModel choices/messages to avoid Pydantic serializer warnings (#18972)
* Normalize BaseModel choices + suppress serializer warnings

* Fix ModelResponse normalization and test deps
2026-01-14 03:40:11 +05:30