forked from phoenix/litellm-mirror
(fix) log cache hits on SpendLogs table
This commit is contained in:
parent
bf851ef19a
commit
2f3765a03f
2 changed files with 10 additions and 0 deletions
|
@ -593,6 +593,12 @@ async def track_cost_callback(
|
||||||
"user_api_key_user_id", None
|
"user_api_key_user_id", None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if kwargs.get("cache_hit", False) == True:
|
||||||
|
response_cost = 0.0
|
||||||
|
verbose_proxy_logger.info(
|
||||||
|
f"Cache Hit: response_cost {response_cost}, for user_id {user_id}"
|
||||||
|
)
|
||||||
|
|
||||||
verbose_proxy_logger.info(
|
verbose_proxy_logger.info(
|
||||||
f"response_cost {response_cost}, for user_id {user_id}"
|
f"response_cost {response_cost}, for user_id {user_id}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1003,6 +1003,10 @@ def get_logging_payload(kwargs, response_obj, start_time, end_time):
|
||||||
cache_key = litellm.cache.get_cache_key(**kwargs)
|
cache_key = litellm.cache.get_cache_key(**kwargs)
|
||||||
else:
|
else:
|
||||||
cache_key = "Cache OFF"
|
cache_key = "Cache OFF"
|
||||||
|
if cache_hit == True:
|
||||||
|
import time
|
||||||
|
|
||||||
|
id = f"{id}_cache_hit{time.time()}" # SpendLogs does not allow duplicate request_id
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"request_id": id,
|
"request_id": id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue