From 47944bbb581ed7a4282838de8827933e7861d539 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Thu, 22 Oct 2026 23:53:26 -0500 Subject: [PATCH] fix: use TypeError for unprepared Foundry Local audio Satisfy the strict TRY004 CI gate by distinguishing an invalid audio type from an invalid value. Add regression coverage for the rejected input. Files changed: litellm/llms/foundry_local/audio_transcription/transformation.py; tests/unit/llms/foundry_local/chat/test_transformation.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4aafcdf7-d0d2-4be7-843f-e52bb16c92da --- .../foundry_local/audio_transcription/transformation.py | 2 +- tests/unit/llms/foundry_local/chat/test_transformation.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/litellm/llms/foundry_local/audio_transcription/transformation.py b/litellm/llms/foundry_local/audio_transcription/transformation.py index 8463d7578a4..6c400fc33f5 100644 --- a/litellm/llms/foundry_local/audio_transcription/transformation.py +++ b/litellm/llms/foundry_local/audio_transcription/transformation.py @@ -63,7 +63,7 @@ class FoundryLocalAudioTranscriptionConfig(OpenAIWhisperAudioTranscriptionConfig litellm_params: Mapping[str, object], ) -> AudioTranscriptionRequestData: if not isinstance(audio_file, Path): - raise ValueError("Foundry Local audio must be prepared using audio_file_context") + raise TypeError("Foundry Local audio must be prepared using audio_file_context") if optional_params.get("stream"): raise ValueError("Streaming Foundry Local transcription is not supported by this integration") return AudioTranscriptionRequestData( diff --git a/tests/unit/llms/foundry_local/chat/test_transformation.py b/tests/unit/llms/foundry_local/chat/test_transformation.py index 8123c763436..10ff927b5d7 100644 --- a/tests/unit/llms/foundry_local/chat/test_transformation.py +++ b/tests/unit/llms/foundry_local/chat/test_transformation.py @@ -320,6 +320,12 @@ def test_should_reject_bare_audio_paths_and_unsupported_transcription_options(tm config.get_complete_url(None, None, "whisper-tiny", {}, {}) +def test_should_require_prepared_audio_for_transcription() -> None: + config: Final = FoundryLocalAudioTranscriptionConfig() + with pytest.raises(TypeError, match="must be prepared using audio_file_context"): + config.transform_audio_transcription_request("whisper-tiny", b"audio-content", {}, {}) + + @pytest.mark.asyncio @pytest.mark.parametrize("stream", [False, True]) async def test_should_complete_chat_asynchronously_over_foundry_http_service(stream: bool) -> None: