mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
(perf) - only use response_cost_calculator 1 time per request. (Don't re-use the same helper twice per call ) (#7709)
* fix get_llm_provider for aiohttp openai * fix _success_handler_helper_fn
This commit is contained in:
parent
9db7893402
commit
d21e4dedbd
1 changed files with 11 additions and 6 deletions
|
@ -888,13 +888,9 @@ class Logging(LiteLLMLoggingBaseClass):
|
|||
or isinstance(result, Batch)
|
||||
or isinstance(result, FineTuningJob)
|
||||
):
|
||||
## RESPONSE COST ##
|
||||
self.model_call_details["response_cost"] = (
|
||||
self._response_cost_calculator(result=result)
|
||||
)
|
||||
|
||||
## HIDDEN PARAMS ##
|
||||
if hasattr(result, "_hidden_params"):
|
||||
hidden_params = getattr(result, "_hidden_params", {})
|
||||
if hidden_params:
|
||||
# add to metadata for logging
|
||||
if self.model_call_details.get("litellm_params") is not None:
|
||||
self.model_call_details["litellm_params"].setdefault(
|
||||
|
@ -913,6 +909,15 @@ class Logging(LiteLLMLoggingBaseClass):
|
|||
] = getattr(
|
||||
result, "_hidden_params", {}
|
||||
)
|
||||
## RESPONSE COST - Only calculate if not in hidden_params ##
|
||||
if "response_cost" in hidden_params:
|
||||
self.model_call_details["response_cost"] = hidden_params[
|
||||
"response_cost"
|
||||
]
|
||||
else:
|
||||
self.model_call_details["response_cost"] = (
|
||||
self._response_cost_calculator(result=result)
|
||||
)
|
||||
## STANDARDIZED LOGGING PAYLOAD
|
||||
|
||||
self.model_call_details["standard_logging_object"] = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue