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 is in `b{} convert it to ModelResponse
cached_response = cached_result.get("response") cached_response = cached_result.get("response")
try: try:
cached_response = json.loads( if isinstance(cached_response, dict):
cached_response pass
) # Convert string to dictionary else:
cached_response = json.loads(
cached_response
) # Convert string to dictionary
except: except:
cached_response = ast.literal_eval(cached_response) cached_response = ast.literal_eval(cached_response)
return cached_response return cached_response