mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix(mistral/tts): ensure /v1 prefix in speech URL
This commit is contained in:
parent
25bb8c92e3
commit
04f9904f69
2 changed files with 21 additions and 2 deletions
|
|
@ -115,8 +115,9 @@ class MistralTextToSpeechConfig(BaseTextToSpeechConfig):
|
|||
api_base: str | None,
|
||||
litellm_params: Mapping[str, object],
|
||||
) -> str:
|
||||
base_url: Final = api_base or get_secret_str("MISTRAL_API_BASE") or self.TTS_BASE_URL
|
||||
return f"{base_url.rstrip('/')}/audio/speech"
|
||||
base_url: Final = (api_base or get_secret_str("MISTRAL_API_BASE") or self.TTS_BASE_URL).rstrip("/")
|
||||
normalized_base: Final = base_url if base_url.endswith("/v1") else f"{base_url}/v1"
|
||||
return f"{normalized_base}/audio/speech"
|
||||
|
||||
def transform_text_to_speech_request(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -101,6 +101,24 @@ def test_get_complete_url_custom_base():
|
|||
assert url == "https://custom.api.example.com/v1/audio/speech"
|
||||
|
||||
|
||||
def test_get_complete_url_host_only_base_adds_v1(monkeypatch: pytest.MonkeyPatch):
|
||||
monkeypatch.delenv("MISTRAL_API_BASE", raising=False)
|
||||
config: Final = MistralTextToSpeechConfig()
|
||||
url: Final = config.get_complete_url(
|
||||
model="voxtral-mini-tts-2603",
|
||||
api_base="https://custom.api.example.com",
|
||||
litellm_params={},
|
||||
)
|
||||
assert url == "https://custom.api.example.com/v1/audio/speech"
|
||||
|
||||
|
||||
def test_get_complete_url_env_base_without_v1_adds_v1(monkeypatch: pytest.MonkeyPatch):
|
||||
monkeypatch.setenv("MISTRAL_API_BASE", "https://api.mistral.ai")
|
||||
config: Final = MistralTextToSpeechConfig()
|
||||
url: Final = config.get_complete_url(model="voxtral-mini-tts-2603", api_base=None, litellm_params={})
|
||||
assert url == SPEECH_URL
|
||||
|
||||
|
||||
def test_validate_environment_sets_bearer_header():
|
||||
config: Final = MistralTextToSpeechConfig()
|
||||
headers: Final = config.validate_environment(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue