feat: add a health_check_voice param
This commit is contained in:
parent
8a880ccd2f
commit
32b2ebee9f
@ -119,8 +119,11 @@ model_list:
|
||||
api_key: "os.environ/OPENAI_API_KEY"
|
||||
model_info:
|
||||
mode: audio_speech
|
||||
health_check_voice: alloy
|
||||
```
|
||||
|
||||
You can specify a `health_check_voice` if you need to use a voice other than "alloy".
|
||||
|
||||
### Rerank Models
|
||||
|
||||
To run rerank health checks, specify the mode as "rerank" in your config for the relevant model.
|
||||
|
||||
@ -5704,9 +5704,8 @@ async def ahealth_check(
|
||||
input=input or ["test"],
|
||||
),
|
||||
"audio_speech": lambda: litellm.aspeech(
|
||||
**_filter_model_params(model_params),
|
||||
**{**_filter_model_params(model_params), **({"voice": "alloy"} if "voice" not in _filter_model_params(model_params) else {})},
|
||||
input=prompt or "test",
|
||||
voice="alloy",
|
||||
),
|
||||
"audio_transcription": lambda: litellm.atranscription(
|
||||
**_filter_model_params(model_params),
|
||||
|
||||
@ -137,11 +137,14 @@ def _update_litellm_params_for_health_check(
|
||||
|
||||
- gets a short `messages` param for health check
|
||||
- updates the `model` param with the `health_check_model` if it exists Doc: https://docs.litellm.ai/docs/proxy/health#wildcard-routes
|
||||
- updates the `voice` param with the `health_check_voice` for `audio_speech` mode if it exists Doc: https://docs.litellm.ai/docs/proxy/health#text-to-speech-models
|
||||
"""
|
||||
litellm_params["messages"] = _get_random_llm_message()
|
||||
_health_check_model = model_info.get("health_check_model", None)
|
||||
if _health_check_model is not None:
|
||||
litellm_params["model"] = _health_check_model
|
||||
if model_info.get("mode", None) == "audio_speech":
|
||||
litellm_params["voice"] = model_info.get("health_check_voice", "alloy")
|
||||
return litellm_params
|
||||
|
||||
|
||||
|
||||
@ -229,6 +229,7 @@ def test_update_litellm_params_for_health_check():
|
||||
Test if _update_litellm_params_for_health_check correctly:
|
||||
1. Updates messages with a random message
|
||||
2. Updates model name when health_check_model is provided
|
||||
3. Updates voice when health_check_voice is provided for audio_speech mode
|
||||
"""
|
||||
from litellm.proxy.health_check import _update_litellm_params_for_health_check
|
||||
|
||||
@ -258,6 +259,34 @@ def test_update_litellm_params_for_health_check():
|
||||
assert isinstance(updated_params["messages"], list)
|
||||
assert updated_params["model"] == "gpt-4"
|
||||
|
||||
# Test with health_check_voice for audio_speech mode
|
||||
model_info = {"mode": "audio_speech", "health_check_voice": "en-US-JennyNeural"}
|
||||
litellm_params = {
|
||||
"model": "gpt-4",
|
||||
"api_key": "fake_key",
|
||||
}
|
||||
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
|
||||
assert "voice" in updated_params
|
||||
assert updated_params["voice"] == "en-US-JennyNeural"
|
||||
|
||||
# Test without health_check_voice for audio_speech mode
|
||||
model_info = {"mode": "audio_speech"}
|
||||
litellm_params = {
|
||||
"model": "gpt-4",
|
||||
"api_key": "fake_key",
|
||||
}
|
||||
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
|
||||
assert "voice" in updated_params
|
||||
assert updated_params["voice"] == "alloy"
|
||||
|
||||
# Test with health_check_voice for non-audio_speech mode
|
||||
model_info = {"mode": "chat", "health_check_voice": "en-US-JennyNeural"}
|
||||
litellm_params = {
|
||||
"model": "gpt-4",
|
||||
"api_key": "fake_key",
|
||||
}
|
||||
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
|
||||
assert "voice" not in updated_params
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_perform_health_check_with_health_check_model():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user