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(realtime): keep a Muse turn active for turnless partials after speechEnd
ryan-crabbe-berri4647cd121593
diff --git a/litellm/llms/meta/realtime/transformation.py b/litellm/llms/meta/realtime/transformation.pyindex 549db60be85..1b8943f0cee 100644--- a/litellm/llms/meta/realtime/transformation.py+++ b/litellm/llms/meta/realtime/transformation.py@@ -517,7 +517,6 @@ class MuseEventTransformer:def _speech_end(self, message: Mapping[str, JsonValue]) -> _TurnState:turn: Final = self._turn(_required_turn_id(message, "speechEnd"))turn.stopped = True- self._release_active(turn)return turndef _speech_complete(self, message: Mapping[str, JsonValue]) -> _TurnState:diff --git a/tests/test_litellm/llms/meta/realtime/test_meta_realtime_transformation.py b/tests/test_litellm/llms/meta/realtime/test_meta_realtime_transformation.pyindex 3a4c0591fb5..a5d7e47fb65 100644--- a/tests/test_litellm/llms/meta/realtime/test_meta_realtime_transformation.py+++ b/tests/test_litellm/llms/meta/realtime/test_meta_realtime_transformation.py@@ -241,6 +241,25 @@ def test_speech_end_then_speech_complete_emits_stopped_then_completed():assert completed[0]["transcript"] == "done"+def test_turnless_partial_between_speech_end_and_speech_complete_stays_on_that_turn():+ transformer = MuseEventTransformer()+ transformer.transform(json.loads(_event("speechStart", turnId="turn-1")))+ transformer.transform(json.loads(_event("transcript", transcript="what is", final=False)))+ transformer.transform(json.loads(_event("speechEnd", turnId="turn-1")))++ post_processed = transformer.transform(+ json.loads(_event("transcript", transcript="what is the weather", final=False))+ )+ completed = transformer.transform(+ json.loads(_event("speechComplete", turnId="turn-1", transcript="What is the weather?"))+ )++ assert _typed(post_processed) == [("conversation.item.input_audio_transcription.delta", "turn-1")]+ assert post_processed[0]["delta"] == " the weather"+ assert _typed(completed) == [("conversation.item.input_audio_transcription.completed", "turn-1")]+ assert completed[0]["transcript"] == "What is the weather?"++def _typed(events: tuple[dict[str, object], ...]) -> list[tuple[object, object]]:return [(event["type"], event["item_id"]) for event in events]