use proper bedrock model name in health check (#15808)

This commit is contained in:
nuernber 2025-10-22 15:24:57 -07:00 committed by GitHub
parent ec6a5ffa2d
commit 799a2b624a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -138,6 +138,7 @@ 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
- updates the `model` param with the Bedrock base model name if it is a Bedrock model
"""
litellm_params["messages"] = _get_random_llm_message()
_health_check_model = model_info.get("health_check_model", None)
@ -145,6 +146,9 @@ def _update_litellm_params_for_health_check(
litellm_params["model"] = _health_check_model
if model_info.get("mode", None) == "audio_speech":
litellm_params["voice"] = model_info.get("health_check_voice", "alloy")
if "bedrock" in litellm_params["model"]:
from litellm.llms.bedrock.common_utils import BedrockModelInfo
litellm_params["model"] = BedrockModelInfo.get_base_model(litellm_params["model"])
return litellm_params

View file

@ -304,6 +304,15 @@ def test_update_litellm_params_for_health_check():
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
assert "voice" not in updated_params
# Test with Bedrock model
model_info = {}
litellm_params = {
"model": "bedrock/us-gov-west-1/anthropic.claude-3-7-sonnet-20250219-v1:0",
"api_key": "fake_key",
}
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
assert updated_params["model"] == "anthropic.claude-3-7-sonnet-20250219-v1:0"
@pytest.mark.asyncio
async def test_perform_health_check_with_health_check_model():
"""