forked from phoenix/litellm-mirror
fix(caching.py): fix print statements
This commit is contained in:
parent
bdd2004691
commit
d6537a05ca
3 changed files with 23 additions and 4 deletions
|
@ -142,7 +142,9 @@ class RedisCache(BaseCache):
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# NON blocking - notify users Redis is throwing an exception
|
# NON blocking - notify users Redis is throwing an exception
|
||||||
print_verbose("LiteLLM Caching: set() - Got exception from REDIS : ", e)
|
print_verbose(
|
||||||
|
f"LiteLLM Redis Caching: async set() - Got exception from REDIS : {str(e)}"
|
||||||
|
)
|
||||||
|
|
||||||
async def async_set_cache_pipeline(self, cache_list, ttl=None):
|
async def async_set_cache_pipeline(self, cache_list, ttl=None):
|
||||||
"""
|
"""
|
||||||
|
@ -905,8 +907,11 @@ class Cache:
|
||||||
|
|
||||||
# for streaming, we use preset_cache_key. It's created in wrapper(), we do this because optional params like max_tokens, get transformed for bedrock -> max_new_tokens
|
# for streaming, we use preset_cache_key. It's created in wrapper(), we do this because optional params like max_tokens, get transformed for bedrock -> max_new_tokens
|
||||||
if kwargs.get("litellm_params", {}).get("preset_cache_key", None) is not None:
|
if kwargs.get("litellm_params", {}).get("preset_cache_key", None) is not None:
|
||||||
print_verbose(f"\nReturning preset cache key: {cache_key}")
|
_preset_cache_key = kwargs.get("litellm_params", {}).get(
|
||||||
return kwargs.get("litellm_params", {}).get("preset_cache_key", None)
|
"preset_cache_key", None
|
||||||
|
)
|
||||||
|
print_verbose(f"\nReturning preset cache key: {_preset_cache_key}")
|
||||||
|
return _preset_cache_key
|
||||||
|
|
||||||
# sort kwargs by keys, since model: [gpt-4, temperature: 0.2, max_tokens: 200] == [temperature: 0.2, max_tokens: 200, model: gpt-4]
|
# sort kwargs by keys, since model: [gpt-4, temperature: 0.2, max_tokens: 200] == [temperature: 0.2, max_tokens: 200, model: gpt-4]
|
||||||
completion_kwargs = [
|
completion_kwargs = [
|
||||||
|
|
|
@ -4,6 +4,10 @@ model_list:
|
||||||
model: openai/my-fake-model
|
model: openai/my-fake-model
|
||||||
api_key: my-fake-key
|
api_key: my-fake-key
|
||||||
api_base: http://0.0.0.0:8080
|
api_base: http://0.0.0.0:8080
|
||||||
|
- model_name: gpt-3.5-turbo
|
||||||
|
litellm_params:
|
||||||
|
model: gpt-3.5-turbo-1106
|
||||||
|
api_key: os.environ/OPENAI_API_KEY
|
||||||
|
|
||||||
general_settings:
|
general_settings:
|
||||||
master_key: sk-1234
|
master_key: sk-1234
|
||||||
|
|
|
@ -1112,15 +1112,25 @@ async def update_database(
|
||||||
max_budget=max_user_budget,
|
max_budget=max_user_budget,
|
||||||
user_email=None,
|
user_email=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
existing_user_obj.spend = (
|
existing_user_obj.spend = (
|
||||||
existing_user_obj.spend + response_cost
|
existing_user_obj.spend + response_cost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
user_object_json = {**existing_user_obj.json(exclude_none=True)}
|
||||||
|
|
||||||
|
user_object_json["model_max_budget"] = json.dumps(
|
||||||
|
user_object_json["model_max_budget"]
|
||||||
|
)
|
||||||
|
user_object_json["model_spend"] = json.dumps(
|
||||||
|
user_object_json["model_spend"]
|
||||||
|
)
|
||||||
|
|
||||||
await prisma_client.db.litellm_usertable.upsert(
|
await prisma_client.db.litellm_usertable.upsert(
|
||||||
where={"user_id": end_user_id},
|
where={"user_id": end_user_id},
|
||||||
data={
|
data={
|
||||||
"create": {**existing_user_obj.json(exclude_none=True)},
|
"create": user_object_json,
|
||||||
"update": {"spend": {"increment": response_cost}},
|
"update": {"spend": {"increment": response_cost}},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue