mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-28 06:23:07 +00:00
test(streaming): pin that reasoning_items are concatenated across chunks
The reasoning_items fix landed upstream. Its test puts every item in the last chunk, so an aggregation that read only the first or last chunk would still pass. Add one case with an item in each of two chunks and expect both, in order.
This commit is contained in:
parent
b6f91a221b
commit
c7d74f7562
1 changed files with 41 additions and 0 deletions
|
|
@ -2517,3 +2517,44 @@ def test_stream_chunk_builder_keeps_reasoning_items_on_text_only_replies():
|
|||
assert response is not None
|
||||
assert response.choices[0].message.content == "Hello world"
|
||||
assert response.choices[0].message.reasoning_items == reasoning_items
|
||||
|
||||
|
||||
def test_stream_chunk_builder_concatenates_reasoning_items_from_every_chunk():
|
||||
from litellm.types.utils import Delta, ModelResponseStream, StreamingChoices
|
||||
|
||||
first: Final = {"type": "reasoning", "id": "rs_1", "summary": [], "encrypted_content": "enc_1"}
|
||||
second: Final = {"type": "reasoning", "id": "rs_2", "summary": [], "encrypted_content": "enc_2"}
|
||||
chunks: Final = [
|
||||
ModelResponseStream(
|
||||
id="chatcmpl-rs",
|
||||
created=1,
|
||||
model="gpt-5.5",
|
||||
object="chat.completion.chunk",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason=None,
|
||||
index=0,
|
||||
delta=Delta(content="Hello", role="assistant", reasoning_items=[first]),
|
||||
)
|
||||
],
|
||||
),
|
||||
ModelResponseStream(
|
||||
id="chatcmpl-rs",
|
||||
created=1,
|
||||
model="gpt-5.5",
|
||||
object="chat.completion.chunk",
|
||||
choices=[
|
||||
StreamingChoices(
|
||||
finish_reason="stop",
|
||||
index=0,
|
||||
delta=Delta(content=" world", role="assistant", reasoning_items=[second]),
|
||||
)
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
response: Final = stream_chunk_builder(chunks=list(chunks))
|
||||
|
||||
assert response is not None
|
||||
assert response.choices[0].message.content == "Hello world"
|
||||
assert response.choices[0].message.reasoning_items == [first, second]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue