From 9a35f347abcefa7f9ef14cc311972f93cd4d1f92 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 14 Dec 2023 16:20:29 +0530 Subject: [PATCH] (test) - caching - override when caching = False --- litellm/tests/test_caching.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/litellm/tests/test_caching.py b/litellm/tests/test_caching.py index 978da57d6..24b7f37a8 100644 --- a/litellm/tests/test_caching.py +++ b/litellm/tests/test_caching.py @@ -372,6 +372,39 @@ def test_custom_redis_cache_with_key(): # test_custom_redis_cache_with_key() +def test_cache_override(): + # test if we can override the cache, when `caching=False` but litellm.cache = Cache() is set + # in this case it should not return cached responses + litellm.cache = Cache() + print("Testing cache override") + litellm.set_verbose=True + + # test embedding + response1 = embedding( + model = "text-embedding-ada-002", + input=[ + "hello who are you" + ], + caching = False + ) + + + start_time = time.time() + + response2 = embedding( + model = "text-embedding-ada-002", + input=[ + "hello who are you" + ], + caching = False + ) + + end_time = time.time() + print(f"Embedding 2 response time: {end_time - start_time} seconds") + + assert end_time - start_time > 0.1 # ensure 2nd response comes in over 0.1s. This should not be cached. +# test_cache_override() + def test_custom_redis_cache_params(): # test if we can init redis with **kwargs