Merge pull request #5573 from BerriAI/litellm_add_rerank_spend_tracking

[Feat] Add cost tracking for cohere rerank
This commit is contained in:
Ishaan Jaff 2024-09-06 18:11:30 -07:00 committed by GitHub
commit 64a828b455
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 98 additions and 1 deletions

View file

@ -30,6 +30,7 @@ from litellm.integrations.custom_logger import CustomLogger
from litellm.litellm_core_utils.redact_messages import (
redact_message_input_output_from_logging,
)
from litellm.rerank_api.types import RerankResponse
from litellm.types.llms.openai import HttpxBinaryResponseContent
from litellm.types.router import SPECIAL_MODEL_INFO_PARAMS
from litellm.types.utils import (
@ -525,6 +526,7 @@ class Logging:
TranscriptionResponse,
TextCompletionResponse,
HttpxBinaryResponseContent,
RerankResponse,
],
cache_hit: Optional[bool] = None,
):
@ -588,6 +590,7 @@ class Logging:
or isinstance(result, TranscriptionResponse)
or isinstance(result, TextCompletionResponse)
or isinstance(result, HttpxBinaryResponseContent) # tts
or isinstance(result, RerankResponse)
):
## RESPONSE COST ##
self.model_call_details["response_cost"] = (