mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
test(audio): assert dropped transcription streams by error type and cause on SDK 3
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Waiting to run
LiteLLM Rust DB / db-queries (push) Waiting to run
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Waiting to run
LiteLLM Rust DB / db-queries (push) Waiting to run
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Main's transcription streaming tests matched the upstream transport message, which openai SDK 3 replaces with "Connection error." when a stream read fails. Assert the LiteLLM APIConnectionError and the dropped connection in its cause chain instead, which holds on SDK 2 and 3.
This commit is contained in:
parent
35135f478e
commit
cea07b6064
2 changed files with 5 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ from litellm.litellm_core_utils.audio_utils.transcription_streaming import (
|
|||
litellm_exception_mapper,
|
||||
wrap_transcription_stream,
|
||||
)
|
||||
from litellm.llms.custom_httpx.transport_errors import TransportErrorKind, chained_transport_error_kind
|
||||
from litellm.types.utils import TranscriptionResponse
|
||||
|
||||
_STARTED_AT: Final = datetime.datetime(2026, 10, 28, 12, 0, 0) # noqa: DTZ001 # callback timestamps use the legacy naive contract
|
||||
|
|
@ -177,10 +178,12 @@ async def test_a_stream_the_upstream_drops_mid_transcript_raises_a_litellm_error
|
|||
model="openai/gpt-transcribe", file=("sample.wav", b"audio"), stream=True, client=upstream
|
||||
)
|
||||
|
||||
with pytest.raises(litellm.APIConnectionError, match="peer closed connection"):
|
||||
with pytest.raises(litellm.APIConnectionError) as raised:
|
||||
async for _ in stream:
|
||||
pass
|
||||
|
||||
assert chained_transport_error_kind(raised.value) is TransportErrorKind.DROPPED_CONNECTION
|
||||
|
||||
|
||||
class _FailureHookCounter(CustomLogger):
|
||||
def __init__(self) -> None:
|
||||
|
|
|
|||
|
|
@ -1037,7 +1037,7 @@ def test_streamed_transcription_error_mid_stream_ends_with_an_error_event_and_ru
|
|||
assert tuple(frame.get("delta") for frame in frames[:2]) == ("hello ", "world")
|
||||
assert len(frames) == 3
|
||||
assert data_lines[-1] == "[DONE]"
|
||||
assert "upstream connection dropped" in frames[2]["error"]["message"]
|
||||
assert "APIConnectionError" in frames[2]["error"]["message"]
|
||||
assert "/srv/app/stt_stream.py" not in frames[2]["error"]["message"]
|
||||
assert "stt.internal.corp" not in frames[2]["error"]["message"]
|
||||
assert set(frames[2]["error"]) == {"message", "type", "param", "code"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue