mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-01 07:03:02 +00:00
fix(passthrough): fit the Deepgram listen unpriced refusal in a WebSocket close frame (#49502)
This commit is contained in:
parent
3bd75f1258
commit
ead8aa82ef
2 changed files with 17 additions and 1 deletions
|
|
@ -3614,7 +3614,9 @@ async def deepgram_listen_websocket_route(
|
|||
if not deepgram_listen_is_priced(target):
|
||||
await websocket.close(
|
||||
code=1008,
|
||||
reason=_DEEPGRAM_WS_UNPRICED_REASON.format(registry_key=deepgram_listen_registry_key(target)),
|
||||
reason=truncated_close_reason(
|
||||
_DEEPGRAM_WS_UNPRICED_REASON.format(registry_key=deepgram_listen_registry_key(target))
|
||||
),
|
||||
)
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -286,6 +286,20 @@ async def test_deepgram_listen_refuses_sessions_it_cannot_price(query, missing_k
|
|||
assert "dg-provider-key" not in websocket.closed[1]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_deepgram_listen_refusal_for_a_long_unpriced_model_fits_a_close_frame(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
monkeypatch.delenv("DEEPGRAM_API_BASE", raising=False)
|
||||
monkeypatch.setenv("DEEPGRAM_API_KEY", "dg-provider-key")
|
||||
websocket: Final = _FakeWebSocket("/deepgram/v1/listen", "model=" + "%C3%A9" * 100)
|
||||
|
||||
relay: Final = await _serve(websocket)
|
||||
|
||||
assert relay.calls == []
|
||||
assert websocket.closed == (1008, "No streaming price for 'deepgram/streaming/" + "é" * 40)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_deepgram_listen_relays_once_the_operator_prices_the_model(monkeypatch):
|
||||
monkeypatch.delenv("DEEPGRAM_API_BASE", raising=False)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue