fix(tests): fix repeating chunk and audio usage streaming tests (#23061)
- Replace ModelResponse(stream=True) with ModelResponseStream in test_unit_test_custom_stream_wrapper_repeating_chunk — stream=True stores delta as a plain dict causing AttributeError in CustomStreamWrapper - Accept MidStreamFallbackError alongside InternalServerError in the repeating-chunk safety check assertion - Add @pytest.mark.flaky(retries=3) to the live OpenAI audio output usage test
This commit is contained in:
parent
a50a84c16c
commit
e8a7116899
@ -636,6 +636,7 @@ def test_stream_chunk_builder_openai_prompt_caching():
|
||||
assert response_usage_value == v
|
||||
|
||||
|
||||
@pytest.mark.flaky(retries=3, delay=2)
|
||||
def test_stream_chunk_builder_openai_audio_output_usage():
|
||||
from pydantic import BaseModel
|
||||
from openai import OpenAI
|
||||
|
||||
@ -3075,22 +3075,18 @@ def test_unit_test_custom_stream_wrapper_repeating_chunk(
|
||||
"""
|
||||
litellm.set_verbose = False
|
||||
chunks = [
|
||||
litellm.ModelResponse(
|
||||
**{
|
||||
"id": "chatcmpl-123",
|
||||
"object": "chat.completion.chunk",
|
||||
"created": 1694268190,
|
||||
"model": "gpt-3.5-turbo-0125",
|
||||
"system_fingerprint": "fp_44709d6fcb",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"delta": {"content": chunk_value},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
},
|
||||
stream=True,
|
||||
litellm.ModelResponseStream(
|
||||
id="chatcmpl-123",
|
||||
created=1694268190,
|
||||
model="gpt-3.5-turbo-0125",
|
||||
system_fingerprint="fp_44709d6fcb",
|
||||
choices=[
|
||||
{
|
||||
"index": 0,
|
||||
"delta": {"content": chunk_value},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
)
|
||||
] * loop_amount
|
||||
completion_stream = ModelResponseListIterator(model_responses=chunks)
|
||||
@ -3113,7 +3109,7 @@ def test_unit_test_custom_stream_wrapper_repeating_chunk(
|
||||
print(f"expected_chunk_fail: {expected_chunk_fail}")
|
||||
|
||||
if (loop_amount > litellm.REPEATED_STREAMING_CHUNK_LIMIT) and expected_chunk_fail:
|
||||
with pytest.raises(litellm.InternalServerError):
|
||||
with pytest.raises((litellm.InternalServerError, litellm.exceptions.MidStreamFallbackError)):
|
||||
for chunk in response:
|
||||
continue
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user