From 63eb58a82b363e3617293db53f96c9b0ffbd3568 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Mon, 13 Apr 2026 16:59:32 -0700 Subject: [PATCH] fix(test/audio): skip empty-choices chunks in streaming response check OpenAI streaming with include_usage=True emits a final usage chunk with choices=[]. check_streaming_response() assumed every chunk has at least one choice and crashed with IndexError on chunk.choices[0]. Add an early-continue guard to skip usage-only chunks. --- tests/llm_translation/test_gpt4o_audio.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/llm_translation/test_gpt4o_audio.py b/tests/llm_translation/test_gpt4o_audio.py index f41dabb6665..1b6d35484ba 100644 --- a/tests/llm_translation/test_gpt4o_audio.py +++ b/tests/llm_translation/test_gpt4o_audio.py @@ -34,6 +34,8 @@ async def check_streaming_response(completion): _audio_id = None async for chunk in completion: print(chunk) + if not chunk.choices: # skip usage-only chunks (choices=[]) + continue _choice: StreamingChoices = chunk.choices[0] if _choice.delta.audio is not None: if _choice.delta.audio.get("data") is not None: @@ -84,7 +86,7 @@ async def test_audio_output_from_model(stream): @pytest.mark.asyncio @pytest.mark.parametrize("stream", [True, False]) -@pytest.mark.parametrize("model", ["gpt-4o-audio-preview"]) # "gpt-4o-audio-preview", +@pytest.mark.parametrize("model", ["gpt-4o-audio-preview"]) # "gpt-4o-audio-preview", async def test_audio_input_to_model(stream, model): # Fetch the audio file and convert it to a base64 encoded string audio_format = "pcm16"