Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix code qa

Sameer Kankute7cda0e4edde4
diff --git a/tests/test_litellm/router_utils/test_router_utils_common_utils.py b/tests/test_litellm/router_utils/test_router_utils_common_utils.py
index 8ff1ba45cc2..587b6a97b56 100644
--- a/tests/test_litellm/router_utils/test_router_utils_common_utils.py
+++ b/tests/test_litellm/router_utils/test_router_utils_common_utils.py
@@ -3,6 +3,7 @@ from unittest.mock import Mock
import pytest
+from litellm import Router
from litellm.router_utils.common_utils import (
_deployment_supports_web_search,
filter_team_based_models,
@@ -340,3 +341,22 @@ class TestFilterWebSearchDeployments:
result = filter_web_search_deployments(deployment, request_kwargs)
# Should return the dict unchanged, not filter it
assert result == deployment
+
+
+def test_invalidate_model_group_info_cache():
+ """Test that _invalidate_model_group_info_cache clears the LRU cache."""
+ router = Router(
+ model_list=[
+ {
+ "model_name": "gpt-4",
+ "litellm_params": {"model": "gpt-4", "api_key": "fake-key"},
+ }
+ ]
+ )
+ # Populate the cache
+ router._cached_get_model_group_info("gpt-4")
+ assert router._cached_get_model_group_info.cache_info().currsize > 0
+
+ # Invalidate and verify cache is cleared
+ router._invalidate_model_group_info_cache()
+ assert router._cached_get_model_group_info.cache_info().currsize == 0