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
This commit is contained in:
Bhagirath Mehta 2026-10-22 23:53:26 -05:00
parent 50854b47c6
commit 47944bbb58
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

View file

@ -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(

View file

@ -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: