fix kwargs.get("response_cost")

This commit is contained in:
Ishaan Jaff 2024-10-31 18:53:58 +05:30
parent 9c1270fa0e
commit e7ab928c33

View file

@ -781,7 +781,9 @@ async def _PROXY_track_cost_callback(
)
if standard_logging_payload is None:
raise ValueError("Standard logging payload is missing from kwargs")
response_cost = standard_logging_payload.get("response_cost")
response_cost = standard_logging_payload.get("response_cost") or kwargs.get(
"response_cost", None
) # read from kwargs for backwards compatibility with existing tests
if response_cost is not None:
user_api_key = metadata.get("user_api_key", None)
if kwargs.get("cache_hit", False) is True: