mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
test(proxy): assert the complete reasoning items stream payload
This commit is contained in:
parent
20d4a0d5dc
commit
297d7d50af
1 changed files with 17 additions and 9 deletions
|
|
@ -551,8 +551,6 @@ def test_fast_serialize_simple_model_response_stream_with_usage_returns_none_inv
|
|||
|
||||
|
||||
def test_fast_serialize_simple_model_response_stream_with_reasoning_items_returns_none():
|
||||
"""``reasoning_items`` carries the provider's encrypted reasoning state, which
|
||||
the fast path cannot emit — it must bail so the slow path serializes it."""
|
||||
chunk = _simple_chunk(content="")
|
||||
chunk.choices[0].delta.reasoning_items = [
|
||||
{"id": "rs_abc", "type": "reasoning", "encrypted_content": "ENCRYPTED-BLOB"}
|
||||
|
|
@ -584,17 +582,27 @@ def test_serialize_streaming_chunk_simple_uses_fast_path_bytes():
|
|||
|
||||
|
||||
def test_serialize_streaming_chunk_preserves_reasoning_items():
|
||||
"""End-to-end pin for the bug: a chunk whose only payload beside text is
|
||||
``reasoning_items`` must still reach the wire with those items. The fast
|
||||
path emits ``role``/``content`` only, so it has to decline this chunk."""
|
||||
chunk = _simple_chunk(content="")
|
||||
chunk.choices[0].delta.reasoning_items = [
|
||||
{"id": "rs_abc", "type": "reasoning", "encrypted_content": "ENCRYPTED-BLOB"}
|
||||
]
|
||||
payload = json.loads(_serialize_streaming_chunk(chunk))
|
||||
assert payload["choices"][0]["delta"]["reasoning_items"] == [
|
||||
{"id": "rs_abc", "type": "reasoning", "encrypted_content": "ENCRYPTED-BLOB"}
|
||||
]
|
||||
payload: Final = json.loads(_serialize_streaming_chunk(chunk))
|
||||
assert payload == {
|
||||
"id": "chatcmpl-test",
|
||||
"created": 0,
|
||||
"model": "gpt-4",
|
||||
"object": "chat.completion.chunk",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"delta": {
|
||||
"role": "assistant",
|
||||
"content": "",
|
||||
"reasoning_items": [{"id": "rs_abc", "type": "reasoning", "encrypted_content": "ENCRYPTED-BLOB"}],
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_serialize_streaming_chunk_invalid_input_raises_attribute_error():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue