mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
core/lmproto: allow null logprobs and usage on stream chunks
Providers send logprobs=null (and sometimes usage=null) on SSE choices; accept None so decode does not fail mid-stream.
This commit is contained in:
@@ -245,7 +245,8 @@ class DeltaMessage(Struct):
|
||||
class ChunkChoice(Struct):
|
||||
index: int
|
||||
delta: DeltaMessage
|
||||
logprobs: dict[str, Any] | Unset = UNSET
|
||||
# APIs often send logprobs=null on stream choices.
|
||||
logprobs: dict[str, Any] | None | Unset = UNSET
|
||||
finish_reason: FinishReason | None | Unset = UNSET
|
||||
|
||||
|
||||
@@ -255,4 +256,5 @@ class ChatCompletionChunk(Struct):
|
||||
created: int
|
||||
model: str
|
||||
choices: list[ChunkChoice]
|
||||
usage: dict[str, Any] | Unset = UNSET
|
||||
# Final usage chunk may omit or null usage depending on provider.
|
||||
usage: dict[str, Any] | None | Unset = UNSET
|
||||
|
||||
Reference in New Issue
Block a user