The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(tests): fix repeating chunk and audio usage streaming tests (#23061)
Ishaan Jaffe8a7116899b6
diff --git a/tests/local_testing/test_stream_chunk_builder.py b/tests/local_testing/test_stream_chunk_builder.pyindex ddb1546097c..e5d909812c1 100644--- a/tests/local_testing/test_stream_chunk_builder.py+++ b/tests/local_testing/test_stream_chunk_builder.py@@ -636,6 +636,7 @@ def test_stream_chunk_builder_openai_prompt_caching():assert response_usage_value == v[email protected](retries=3, delay=2)def test_stream_chunk_builder_openai_audio_output_usage():from pydantic import BaseModelfrom openai import OpenAIdiff --git a/tests/local_testing/test_streaming.py b/tests/local_testing/test_streaming.pyindex bbeaacccb00..ef2f89cdaf5 100644--- a/tests/local_testing/test_streaming.py+++ b/tests/local_testing/test_streaming.py@@ -3075,22 +3075,18 @@ def test_unit_test_custom_stream_wrapper_repeating_chunk("""litellm.set_verbose = Falsechunks = [- 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_amountcompletion_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:continueelse: