fix(audio-transcription): keep transcripts out of the shared converter's parse errors

This commit is contained in:
mateo-berri 2026-11-05 16:20:48 -08:00
parent 17e7686beb
commit fb77323780
2 changed files with 21 additions and 2 deletions

View file

@ -1072,9 +1072,10 @@ def convert_to_model_response_object(
if isinstance(e, APIError):
raise
hide_reply: Final = response_type == "audio_transcription"
received_args: Final = dict(
response_object=response_object,
model_response_object=model_response_object,
response_object="<hidden>" if hide_reply else response_object,
model_response_object="<hidden>" if hide_reply else model_response_object,
response_type=response_type,
stream=stream,
start_time=start_time,

View file

@ -2814,6 +2814,24 @@ class TestConvertToModelResponseObjectAudioTranscription:
assert result.usage.output_tokens == 5
assert result.usage.input_token_details.audio_tokens == 4
def test_parse_error_keeps_the_transcript_out_of_the_exception(self):
import traceback
from litellm.types.utils import TranscriptionResponse
transcript: Final = "CANARYTRANSCRIPT customer account ending 2750"
with pytest.raises(Exception, match="Invalid response object") as exc_info:
convert_to_model_response_object(
response_object={"text": transcript, "usage": {"type": "duration", "seconds": "not-a-number"}},
model_response_object=TranscriptionResponse(),
response_type="audio_transcription",
)
rendered: Final = "".join(traceback.format_exception(exc_info.value))
assert "received_args=" in rendered
assert "CANARYTRANSCRIPT" not in rendered
class TestConvertToModelResponseObjectRerank:
def test_basic_rerank(self):
from litellm.types.utils import RerankResponse