Remove prod/ prefix from litellm proxy model path (#12200)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Xingyao Wang
2026-01-12 15:46:09 -05:00
committed by GitHub
parent 3d0aa50450
commit 92baebc4bd
2 changed files with 9 additions and 25 deletions

View File

@@ -73,36 +73,22 @@ PERMITTED_CORS_ORIGINS = [
def build_litellm_proxy_model_path(model_name: str) -> str:
"""
Build the LiteLLM proxy model path based on environment and model name.
This utility constructs the full model path for LiteLLM proxy based on:
- Environment type (staging vs prod)
- The provided model name
"""Build the LiteLLM proxy model path based on model name.
Args:
model_name: The base model name (e.g., 'claude-3-7-sonnet-20250219')
Returns:
The full LiteLLM proxy model path (e.g., 'litellm_proxy/prod/claude-3-7-sonnet-20250219')
The full LiteLLM proxy model path (e.g., 'litellm_proxy/claude-3-7-sonnet-20250219')
"""
if 'prod' in model_name or 'litellm' in model_name or 'proxy' in model_name:
if 'litellm' in model_name:
raise ValueError("Only include model name, don't include prefix")
prefix = 'litellm_proxy/'
if not IS_STAGING_ENV and not IS_LOCAL_ENV:
prefix += 'prod/'
return prefix + model_name
return 'litellm_proxy/' + model_name
def get_default_litellm_model():
"""
Construct proxy for litellm model based on user settings and environment type (staging vs prod)
if not set explicitly
"""
"""Construct proxy for litellm model based on user settings if not set explicitly."""
if LITELLM_DEFAULT_MODEL:
return LITELLM_DEFAULT_MODEL
model = USER_SETTINGS_VERSION_TO_MODEL[CURRENT_USER_SETTINGS_VERSION]

View File

@@ -981,7 +981,7 @@ async def test_has_custom_settings_matches_old_default_model(settings_store):
),
):
settings = Settings(
llm_model='litellm_proxy/prod/claude-3-5-sonnet-20241022',
llm_model='litellm_proxy/claude-3-5-sonnet-20241022',
llm_base_url='http://default.url',
)
@@ -1116,7 +1116,7 @@ async def test_update_settings_upgrades_user_from_old_defaults(
):
# Arrange: User with old version using old defaults
old_version = 1
old_model = 'litellm_proxy/prod/claude-3-5-sonnet-20241022'
old_model = 'litellm_proxy/claude-3-5-sonnet-20241022'
settings = Settings(llm_model=old_model, llm_base_url=LITE_LLM_API_URL)
# Use a consistent test URL
@@ -1137,7 +1137,7 @@ async def test_update_settings_upgrades_user_from_old_defaults(
patch('storage.saas_settings_store.LITE_LLM_API_URL', test_base_url),
patch(
'storage.saas_settings_store.get_default_litellm_model',
return_value='litellm_proxy/prod/claude-opus-4-5-20251101',
return_value='litellm_proxy/claude-opus-4-5-20251101',
),
patch(
'server.auth.token_manager.TokenManager.get_user_info_from_user_id',
@@ -1168,9 +1168,7 @@ async def test_update_settings_upgrades_user_from_old_defaults(
# Assert: Settings upgraded to new defaults
assert updated_settings is not None
assert (
updated_settings.llm_model == 'litellm_proxy/prod/claude-opus-4-5-20251101'
)
assert updated_settings.llm_model == 'litellm_proxy/claude-opus-4-5-20251101'
assert updated_settings.llm_base_url == test_base_url