diff --git a/litellm/tests/test_caching.py b/litellm/tests/test_caching.py index 21ddf1659..9fa728219 100644 --- a/litellm/tests/test_caching.py +++ b/litellm/tests/test_caching.py @@ -926,6 +926,53 @@ def test_cache_override(): # test_cache_override() +@pytest.mark.asyncio +async def test_cache_control_overrides(): + # we use the cache controls to ensure there is no cache hit on this test + litellm.cache = Cache( + type="redis", + host=os.environ["REDIS_HOST"], + port=os.environ["REDIS_PORT"], + password=os.environ["REDIS_PASSWORD"], + ) + print("Testing cache override") + litellm.set_verbose = True + import uuid + + unique_num = str(uuid.uuid4()) + + start_time = time.time() + + response1 = await litellm.acompletion( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "hello who are you" + unique_num, + } + ], + ) + + print(response1) + + await asyncio.sleep(2) + + response2 = await litellm.acompletion( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "hello who are you" + unique_num, + } + ], + cache={"no-cache": True}, + ) + + print(response2) + + assert response1.id != response2.id + + def test_custom_redis_cache_params(): # test if we can init redis with **kwargs try: