fix(router): use string id in test_add_deployment and add defensive str() in register_model

- Change test to use string '100' instead of int 100 for model_info.id
- Add str() conversion in register_model to prevent AttributeError on non-string keys

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-02-28 04:45:10 +00:00
parent e894907431
commit 79e575403f
2 changed files with 3 additions and 2 deletions

View file

@ -2765,8 +2765,9 @@ def register_model(model_cost: Union[str, dict]): # noqa: PLR0915
for key, value in loaded_model_cost.items():
## get model info ##
provider = value.get("litellm_provider", "")
_key_str = str(key)
if provider in _skip_get_model_info_providers or any(
key.startswith(f"{p}/") for p in _skip_get_model_info_providers
_key_str.startswith(f"{p}/") for p in _skip_get_model_info_providers
):
existing_model = litellm.model_cost.get(key, {})
model_cost_key = key

View file

@ -807,7 +807,7 @@ def test_add_deployment(model_list):
deployment = router.get_deployment_by_model_group_name(
model_group_name="gpt-3.5-turbo"
)
deployment["model_info"]["id"] = 100
deployment["model_info"]["id"] = "100"
## Test 1: call user facing function
router.add_deployment(deployment=deployment)