mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
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.
This commit is contained in:
parent
9640dd5765
commit
63eb58a82b
1 changed files with 3 additions and 1 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue