forked from phoenix/litellm-mirror
(fix) cache control logic
This commit is contained in:
parent
965fb6eb2c
commit
81b716d8da
1 changed files with 13 additions and 10 deletions
|
@ -2815,17 +2815,20 @@ def client(original_function):
|
||||||
# if caching is false, don't run this
|
# if caching is false, don't run this
|
||||||
final_embedding_cached_response = None
|
final_embedding_cached_response = None
|
||||||
cache_controls = kwargs.get("cache", None)
|
cache_controls = kwargs.get("cache", None)
|
||||||
|
|
||||||
|
# Check if user has opted out of caching
|
||||||
|
_opted_out_with_cache_controls = (
|
||||||
|
cache_controls and cache_controls.get("no-cache", False) == True
|
||||||
|
)
|
||||||
|
_opted_out_with_caching_param = kwargs.get("caching", True) == False
|
||||||
|
|
||||||
|
# cache is not None and user has not opted out
|
||||||
if (
|
if (
|
||||||
kwargs.get("caching", None) is None
|
litellm.cache is not None
|
||||||
and cache_controls is None
|
and (not _opted_out_with_cache_controls)
|
||||||
and litellm.cache is not None
|
and (not _opted_out_with_caching_param)
|
||||||
) or (
|
):
|
||||||
kwargs.get("caching", False) == True
|
# allow users to control returning cached responses from the completion function
|
||||||
and (
|
|
||||||
cache_controls is not None
|
|
||||||
and cache_controls.get("no-cache", False) != True
|
|
||||||
)
|
|
||||||
): # allow users to control returning cached responses from the completion function
|
|
||||||
# checking cache
|
# checking cache
|
||||||
print_verbose(f"INSIDE CHECKING CACHE")
|
print_verbose(f"INSIDE CHECKING CACHE")
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue