mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(hosted-vllm): preserve explicit transcription content-type
This commit is contained in:
parent
738eb8da6a
commit
cf6c8a5546
2 changed files with 35 additions and 1 deletions
|
|
@ -56,6 +56,10 @@ class HostedVLLMAudioTranscriptionConfig(OpenAIWhisperAudioTranscriptionConfig):
|
|||
litellm_params: dict,
|
||||
) -> AudioTranscriptionRequestData:
|
||||
processed_audio = process_audio_file(audio_file)
|
||||
explicit_content_type = (
|
||||
audio_file[2] if isinstance(audio_file, tuple) and len(audio_file) >= 3 and audio_file[2] else None
|
||||
)
|
||||
content_type = explicit_content_type or processed_audio.content_type
|
||||
extra_body = optional_params.get("extra_body") or {}
|
||||
data = {
|
||||
"model": model,
|
||||
|
|
@ -66,7 +70,7 @@ class HostedVLLMAudioTranscriptionConfig(OpenAIWhisperAudioTranscriptionConfig):
|
|||
"file": (
|
||||
processed_audio.filename,
|
||||
processed_audio.file_content,
|
||||
processed_audio.content_type,
|
||||
content_type,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import httpx
|
|||
import pytest
|
||||
|
||||
import litellm
|
||||
from litellm.llms.hosted_vllm.transcriptions.transformation import (
|
||||
HostedVLLMAudioTranscriptionConfig,
|
||||
)
|
||||
|
||||
|
||||
def _transcription_response() -> httpx.Response:
|
||||
|
|
@ -57,3 +60,30 @@ async def test_transcription_passes_custom_ca_to_async_http_client() -> None:
|
|||
request = client.post.call_args.kwargs
|
||||
assert request["data"] == {"model": "whisper-1"}
|
||||
assert request["files"] == {"file": ("audio.wav", b"audio", "audio/wav")}
|
||||
|
||||
|
||||
def test_transform_request_preserves_explicit_content_type() -> None:
|
||||
config = HostedVLLMAudioTranscriptionConfig()
|
||||
|
||||
request_data = config.transform_audio_transcription_request(
|
||||
model="whisper-1",
|
||||
audio_file=("recording", b"audio", "audio/ogg"),
|
||||
optional_params={"language": "en", "extra_body": {"temperature": 0.1}},
|
||||
litellm_params={},
|
||||
)
|
||||
|
||||
assert request_data.data == {"model": "whisper-1", "language": "en", "temperature": 0.1}
|
||||
assert request_data.files == {"file": ("recording", b"audio", "audio/ogg")}
|
||||
|
||||
|
||||
def test_transform_request_derives_content_type_when_not_supplied() -> None:
|
||||
config = HostedVLLMAudioTranscriptionConfig()
|
||||
|
||||
request_data = config.transform_audio_transcription_request(
|
||||
model="whisper-1",
|
||||
audio_file=("audio.mp3", b"audio"),
|
||||
optional_params={},
|
||||
litellm_params={},
|
||||
)
|
||||
|
||||
assert request_data.files == {"file": ("audio.mp3", b"audio", "audio/mpeg")}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue