Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litellm/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -12502,7 +12502,7 @@ def _common_checks_available_deployment(
# check if aliases set on litellm model alias map
if specific_deployment is True:
return model, self._get_deployment_by_litellm_model(model=model)
elif self.has_model_id(model):
elif model not in self.model_names and self.has_model_id(model):
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
deployment: Final = self.get_deployment(model_id=model)
if deployment is not None:
deployment_model: Final = deployment.litellm_params.model
Expand Down
26 changes: 26 additions & 0 deletions tests/test_litellm/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -15806,3 +15806,29 @@ async def test_an_open_circuit_breaker_skips_the_session_binding_without_a_warni
assert binding is None
assert [record.getMessage() for record in caplog.records if record.levelno >= logging.WARNING] == []
assert any("circuit breaker is open" in record.getMessage() for record in caplog.records)


@pytest.mark.asyncio
async def test_model_name_colliding_with_a_deployment_id_still_load_balances_the_group():
router = litellm.Router(
model_list=[
{
"model_name": "gpt-5-nano",
"litellm_params": {"model": "openai/gpt-5-nano", "api_key": "k", "weight": 0, "mock_response": "A"},
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
"model_info": {"id": "gpt-5-nano"},
},
{
"model_name": "gpt-5-nano",
"litellm_params": {"model": "openai/gpt-5-mini", "api_key": "k", "weight": 1, "mock_response": "B"},
"model_info": {"id": "gpt-5-mini-dep"},
},
],
routing_strategy="simple-shuffle",
)

by_group = await router.acompletion(model="gpt-5-nano", messages=[{"role": "user", "content": "hi"}])
by_id = await router.acompletion(model="gpt-5-mini-dep", messages=[{"role": "user", "content": "hi"}])

assert by_group._hidden_params["model_id"] == "gpt-5-mini-dep"
assert by_group.choices[0].message.content == "B"
assert by_id._hidden_params["model_id"] == "gpt-5-mini-dep"
Loading