mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
(fix) spend tracking per key - when no cache hit
This commit is contained in:
parent
9aa6c5a0b5
commit
b0e642d3d9
1 changed files with 6 additions and 4 deletions
|
@ -706,8 +706,9 @@ async def update_database(
|
|||
await prisma_client.update_data(token=token, data={"spend": new_spend})
|
||||
|
||||
valid_token = user_api_key_cache.get_cache(key=token)
|
||||
valid_token.spend = new_spend
|
||||
user_api_key_cache.set_cache(key=token, value=valid_token)
|
||||
if valid_token is not None:
|
||||
valid_token.spend = new_spend
|
||||
user_api_key_cache.set_cache(key=token, value=valid_token)
|
||||
elif custom_db_client is not None:
|
||||
# Fetch the existing cost for the given token
|
||||
existing_spend_obj = await custom_db_client.get_data(
|
||||
|
@ -730,8 +731,9 @@ async def update_database(
|
|||
)
|
||||
|
||||
valid_token = user_api_key_cache.get_cache(key=token)
|
||||
valid_token.spend = new_spend
|
||||
user_api_key_cache.set_cache(key=token, value=valid_token)
|
||||
if valid_token is not None:
|
||||
valid_token.spend = new_spend
|
||||
user_api_key_cache.set_cache(key=token, value=valid_token)
|
||||
|
||||
async def _insert_spend_log_to_db():
|
||||
# Helper to generate payload to log
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue