(feat) caching - streaming caching support

This commit is contained in:
ishaan-jaff 2023-12-08 11:48:11 -08:00
parent 9b0afbe2cb
commit 6e8ad10991
2 changed files with 54 additions and 19 deletions

View file

@ -262,9 +262,6 @@ class Cache:
cache_key = self.get_cache_key(*args, **kwargs)
if cache_key is not None:
cached_result = self.cache.get_cache(cache_key)
if cached_result != None and 'stream' in kwargs and kwargs['stream'] == True:
# if streaming is true and we got a cache hit, return a generator
return self.generate_streaming_content(cached_result["choices"][0]['message']['content'])
return cached_result
except Exception as e:
logging.debug(f"An exception occurred: {traceback.format_exc()}")