mirror of
https://github.com/NCBM/plyngent.git
synced 2026-07-23 05:55:16 +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:
@@ -47,6 +47,17 @@ def test_delta_accepts_null_content_and_reasoning() -> None:
|
||||
assert delta.reasoning_content is None
|
||||
|
||||
|
||||
def test_chunk_choice_accepts_null_logprobs() -> None:
|
||||
payload = (
|
||||
b'{"id":"1","object":"chat.completion.chunk","created":0,"model":"m",'
|
||||
b'"choices":[{"index":0,"delta":{"content":"x"},"logprobs":null,'
|
||||
b'"finish_reason":null}],"usage":null}'
|
||||
)
|
||||
chunk = msgspec_decode_chunk(payload)
|
||||
assert chunk.choices[0].logprobs is None
|
||||
assert chunk.usage is None
|
||||
|
||||
|
||||
def msgspec_decode_chunk(payload: bytes) -> ChatCompletionChunk:
|
||||
import msgspec
|
||||
|
||||
|
||||
Reference in New Issue
Block a user