(feat) use async_cache for acompletion/aembedding

This commit is contained in:
ishaan-jaff 2023-12-14 16:04:45 +05:30
parent a8e12661c2
commit 008df34ddc
3 changed files with 9 additions and 15 deletions

View file

@ -12,18 +12,6 @@ import time, logging
import json, traceback, ast
from typing import Optional
def get_prompt(*args, **kwargs):
# make this safe checks, it should not throw any exceptions
if len(args) > 1:
messages = args[1]
prompt = " ".join(message["content"] for message in messages)
return prompt
if "messages" in kwargs:
messages = kwargs["messages"]
prompt = " ".join(message["content"] for message in messages)
return prompt
return None
def print_verbose(print_statement):
try:
if litellm.set_verbose:
@ -309,4 +297,9 @@ class Cache:
result = result.model_dump_json()
self.cache.set_cache(cache_key, result, **kwargs)
except Exception as e:
print_verbose(f"LiteLLM Cache: Excepton add_cache: {str(e)}")
traceback.print_exc()
pass
async def _async_add_cache(self, result, *args, **kwargs):
self.add_cache(result, *args, **kwargs)