mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
fix(audio): preserve transcription config compatibility
This commit is contained in:
parent
fd023cc46a
commit
b646791578
4 changed files with 62 additions and 3 deletions
|
|
@ -122,10 +122,9 @@ def get_supported_openai_params(
|
|||
transcription_provider_config = litellm.ProviderConfigManager.get_provider_audio_transcription_config(
|
||||
model=model, provider=LlmProviders.OPENAI
|
||||
)
|
||||
if isinstance(transcription_provider_config, litellm.OpenAIGPTAudioTranscriptionConfig):
|
||||
if transcription_provider_config is not None:
|
||||
return transcription_provider_config.get_supported_openai_params(model=model)
|
||||
else:
|
||||
raise ValueError(f"Unsupported provider config: {transcription_provider_config} for model: {model}")
|
||||
raise ValueError(f"Unsupported provider config: {transcription_provider_config} for model: {model}")
|
||||
return litellm.OpenAIConfig().get_supported_openai_params(model=model)
|
||||
elif custom_llm_provider == "sap":
|
||||
if request_type == "chat_completion":
|
||||
|
|
|
|||
|
|
@ -2148,6 +2148,20 @@ def test_gemini_model_info_reports_transcription_params(monkeypatch):
|
|||
assert "keywords" in model_info["supported_openai_params"]
|
||||
|
||||
|
||||
def test_gemini_live_transcription_dispatch_has_no_batch_params():
|
||||
from litellm.litellm_core_utils.get_supported_openai_params import (
|
||||
get_supported_openai_params,
|
||||
)
|
||||
|
||||
params = get_supported_openai_params(
|
||||
model="gemini-3.5-transcribe-live",
|
||||
custom_llm_provider="gemini",
|
||||
request_type="transcription",
|
||||
)
|
||||
|
||||
assert params is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model, expected_bool",
|
||||
[
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from litellm.litellm_core_utils.audio_utils.utils import (
|
|||
get_audio_file_content_hash,
|
||||
get_audio_file_for_health_check,
|
||||
get_audio_file_name,
|
||||
normalize_transcription_keywords,
|
||||
process_audio_file,
|
||||
)
|
||||
|
||||
|
|
@ -349,6 +350,19 @@ class TestNormalizeTranscriptionLanguageToBcp47:
|
|||
assert normalize_transcription_language_to_bcp47(language) == expected
|
||||
|
||||
|
||||
class TestNormalizeTranscriptionKeywords:
|
||||
@pytest.mark.parametrize(
|
||||
("keywords", "expected"),
|
||||
[
|
||||
(["alpha", "", 42, "beta"], ("alpha", "beta")),
|
||||
("alpha", ()),
|
||||
(None, ()),
|
||||
],
|
||||
)
|
||||
def test_normalization(self, keywords, expected):
|
||||
assert normalize_transcription_keywords(keywords) == expected
|
||||
|
||||
|
||||
class TestResolveSpeechMediaType:
|
||||
@pytest.mark.parametrize(
|
||||
("upstream_content_type", "response_format", "expected"),
|
||||
|
|
|
|||
|
|
@ -864,6 +864,38 @@ def test_gemini_session_update_maps_input_audio_transcription_settings():
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("transcription", "expected"),
|
||||
[
|
||||
("invalid", {}),
|
||||
({}, {}),
|
||||
({"language": "", "keywords": ["", 42]}, {}),
|
||||
(
|
||||
{"language": "pl", "keywords": ["", 42, "term"]},
|
||||
{
|
||||
"languageCodes": ["pl-PL"],
|
||||
"customVocabulary": ["term"],
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_gemini_session_update_handles_input_audio_transcription_values(transcription, expected):
|
||||
config = GeminiRealtimeConfig()
|
||||
session_update = {
|
||||
"type": "session.update",
|
||||
"session": {"input_audio_transcription": transcription},
|
||||
}
|
||||
|
||||
result = config.transform_realtime_request(
|
||||
json.dumps(session_update),
|
||||
"gemini-3.5-transcribe-live",
|
||||
session_configuration_request=None,
|
||||
)
|
||||
|
||||
setup = json.loads(result[0])
|
||||
assert setup["setup"]["inputAudioTranscription"] == expected
|
||||
|
||||
|
||||
def test_gemini_session_update_includes_input_audio_transcription_default():
|
||||
"""Verify _handle_session_update includes inputAudioTranscription default."""
|
||||
config = GeminiRealtimeConfig()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue