From 7384d45ef08973a90381fe2a8242965c12f167ca Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 18 Mar 2025 14:22:30 -0700 Subject: [PATCH] fix type errors on transcription azure --- litellm/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index 85aa0e96a9..e75c23f0fc 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -4951,6 +4951,10 @@ async def atranscription(*args, **kwargs) -> TranscriptionResponse: else: # Call the synchronous function using run_in_executor response = await loop.run_in_executor(None, func_with_context) + if not isinstance(response, TranscriptionResponse): + raise ValueError( + f"Invalid response from transcription provider, expected TranscriptionResponse, but got {type(response)}" + ) return response except Exception as e: custom_llm_provider = custom_llm_provider or "openai" @@ -4984,7 +4988,7 @@ def transcription( max_retries: Optional[int] = None, custom_llm_provider=None, **kwargs, -) -> TranscriptionResponse: +) -> Union[TranscriptionResponse, Coroutine[Any, Any, TranscriptionResponse]]: """ Calls openai + azure whisper endpoints. @@ -5053,7 +5057,9 @@ def transcription( custom_llm_provider=custom_llm_provider, ) - response: Optional[TranscriptionResponse] = None + response: Optional[ + Union[TranscriptionResponse, Coroutine[Any, Any, TranscriptionResponse]] + ] = None if custom_llm_provider == "azure": # azure configs api_base = api_base or litellm.api_base or get_secret_str("AZURE_API_BASE")