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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test_acompletion_caching_on_router
Ishaan Jaffer6cca81291b92
diff --git a/tests/local_testing/test_router_caching.py b/tests/local_testing/test_router_caching.pyindex 6f92d5bea40..52fc5b88584 100644--- a/tests/local_testing/test_router_caching.py+++ b/tests/local_testing/test_router_caching.py@@ -6,7 +6,7 @@ import sysimport timeimport tracebackfrom unittest.mock import patch-+from typing import Unionimport pytestsys.path.insert(@@ -85,21 +85,11 @@ async def test_acompletion_caching_on_router():litellm.set_verbose = Truemodel_list = [{- "model_name": "gpt-3.5-turbo",+ "model_name": "gpt-4.1-nano","litellm_params": {- "model": "gpt-3.5-turbo",+ "model": "gpt-4.1-nano","api_key": os.getenv("OPENAI_API_KEY"),- },- "tpm": 100000,- "rpm": 10000,- },- {- "model_name": "gpt-3.5-turbo",- "litellm_params": {- "model": "azure/chatgpt-v-3",- "api_key": os.getenv("AZURE_API_KEY"),- "api_base": os.getenv("AZURE_API_BASE"),- "api_version": os.getenv("AZURE_API_VERSION"),+ "mock_response": "Hello world",},"tpm": 100000,"rpm": 10000,@@ -120,13 +110,13 @@ async def test_acompletion_caching_on_router():routing_strategy="simple-shuffle",)response1 = await router.acompletion(- model="gpt-3.5-turbo", messages=messages, temperature=1+ model="gpt-4.1-nano", messages=messages, temperature=1)print(f"response1: {response1}")await asyncio.sleep(5) # add cache is async, async sleep for cache to get setresponse2 = await router.acompletion(- model="gpt-3.5-turbo", messages=messages, temperature=1+ model="gpt-4.1-nano", messages=messages, temperature=1)print(f"response2: {response2}")assert response1.id == response2.id@@ -341,8 +331,8 @@ async def test_acompletion_caching_on_router_caching_groups():],)def test_create_correct_redis_cache_instance(- startup_nodes: list[dict] | None,- expected_cache_type: type[RedisClusterCache | RedisCache],+ startup_nodes: Union[list[dict], None],+ expected_cache_type: Union[type[RedisClusterCache], type[RedisCache]],):cache_config = dict(host="mockhost",