Merge pull request #1557 from BerriAI/litellm_emit_spend_logs

feat(utils.py): emit response cost as part of logs
This commit is contained in:
Krish Dholakia 2024-01-22 21:02:40 -08:00 committed by GitHub
commit bedb08bdef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 191 additions and 46 deletions

View file

@ -184,9 +184,11 @@ def test_call_with_user_over_budget(custom_db_client):
# 5. Make a call with a key over budget, expect to fail
setattr(litellm.proxy.proxy_server, "custom_db_client", custom_db_client)
setattr(litellm.proxy.proxy_server, "master_key", "sk-1234")
from litellm._logging import verbose_proxy_logger
from litellm._logging import verbose_proxy_logger, verbose_logger
import logging
litellm.set_verbose = True
verbose_logger.setLevel(logging.DEBUG)
verbose_proxy_logger.setLevel(logging.DEBUG)
try:
@ -234,6 +236,7 @@ def test_call_with_user_over_budget(custom_db_client):
"user_api_key_user_id": user_id,
}
},
"response_cost": 0.00002,
},
completion_response=resp,
)
@ -306,6 +309,7 @@ def test_call_with_user_over_budget_stream(custom_db_client):
"user_api_key_user_id": user_id,
}
},
"response_cost": 0.00002,
},
completion_response=ModelResponse(),
)