mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-23 04:28:07 +00:00
test: add test for get_router_model_info with Deployment object
Verifies that get_router_model_info accepts a Deployment object directly and properly handles the LiteLLM_Params isinstance check.
This commit is contained in:
@@ -2198,3 +2198,33 @@ def test_get_valid_args():
|
||||
# Verify it contains keyword-only arguments too
|
||||
# These are common Router.__init__ parameters
|
||||
assert "assistants_config" in valid_args or "search_tools" in valid_args
|
||||
|
||||
|
||||
def test_get_router_model_info_with_deployment_object():
|
||||
"""Test get_router_model_info accepts Deployment object directly and reuses LiteLLM_Params"""
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "gpt-4",
|
||||
"litellm_params": {"model": "gpt-4", "api_key": "test-key"},
|
||||
"model_info": {"id": "test-id"},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
# Get the Deployment object (not dict)
|
||||
deployment = router.get_deployment(model_id="test-id")
|
||||
assert deployment is not None
|
||||
assert isinstance(deployment, Deployment)
|
||||
assert isinstance(deployment.litellm_params, LiteLLM_Params)
|
||||
|
||||
# Pass Deployment directly (not .model_dump()) - this exercises the isinstance check
|
||||
# that reuses the existing LiteLLM_Params instead of reconstructing it
|
||||
model_info = router.get_router_model_info(
|
||||
deployment=deployment,
|
||||
received_model_name="gpt-4",
|
||||
)
|
||||
|
||||
# Verify we got valid model info back
|
||||
assert model_info is not None
|
||||
assert isinstance(model_info, dict)
|
||||
|
||||
Reference in New Issue
Block a user