fix(transcription): type SDK stream duration metadata explicitly

This commit is contained in:
Emerson Gomes 2026-09-15 12:40:44 -05:00
parent bd43c233ef
commit ac4946477b
No known key found for this signature in database
GPG key ID: D3DF28AB5D1B5E17

View file

@ -7842,7 +7842,7 @@ async def atranscription(
if file is not None:
calculated_duration = calculate_request_duration(file)
if calculated_duration is not None:
setattr(response, "_litellm_audio_duration", calculated_duration)
response._litellm_audio_duration = calculated_duration # pyright: ignore[reportAttributeAccess] # SDK streams permit runtime metadata but do not type this field
return response
if not isinstance(response, TranscriptionResponse):
raise ValueError(
@ -8187,7 +8187,7 @@ def transcription(
calculated_duration: Final = calculate_request_duration(file)
if isinstance(response, (Stream, AsyncStream)):
if calculated_duration is not None:
setattr(response, "_litellm_audio_duration", calculated_duration)
response._litellm_audio_duration = calculated_duration # pyright: ignore[reportAttributeAccess] # SDK streams permit runtime metadata but do not type this field
elif getattr(response, "duration", None) is None and calculated_duration is not None:
response.set_audio_transcription_duration(calculated_duration)