mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
Some OpenAI-compatible providers return null for top_logprobs when logprobs=true but top_logprobs is unset or 0. The OpenAI spec requires top_logprobs to be Array<TopLogprob> (never null), so this triggers Pydantic validation errors while parsing responses. Add a Pydantic v2 field_validator on ChatCompletionTokenLogprob that normalizes None -> [] before type validation. This preserves the typed List[TopLogprob] contract for downstream consumers while remaining narrowly scoped to null only (other invalid types are still rejected). Fixes #21932 |
||
|---|---|---|
| .. | ||
| test_convert_dict_to_chat_completion.py | ||
| test_get_headers.py | ||