fix(caching.py): handle cached_response being a dict not json string

This commit is contained in:
Krrish Dholakia 2024-01-03 17:29:27 +05:30
parent f2210787cd
commit f2da345173

View file

@ -498,9 +498,12 @@ class Cache:
# cached_response is in `b{} convert it to ModelResponse
cached_response = cached_result.get("response")
try:
cached_response = json.loads(
cached_response
) # Convert string to dictionary
if isinstance(cached_response, dict):
pass
else:
cached_response = json.loads(
cached_response
) # Convert string to dictionary
except:
cached_response = ast.literal_eval(cached_response)
return cached_response