mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-27 01:22:18 +00:00
fix: address bug detection findings (cache token order, mutable defaults)
Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
683b421ba0
commit
9de0fcea93
2 changed files with 10 additions and 7 deletions
|
|
@ -365,11 +365,11 @@ def cost_per_token( # noqa: PLR0915
|
|||
if _pt_details is not None:
|
||||
_cache_read_tokens = float(getattr(_pt_details, "cached_tokens", 0) or 0)
|
||||
# OpenAI-compatible providers report cache-write tokens under
|
||||
# either `cache_creation_tokens` or `cache_write_tokens` (kimi-k2
|
||||
# uses the latter). Mirror db_spend_update_writer to stay symmetric.
|
||||
# either `cache_write_tokens` (kimi-k2) or `cache_creation_tokens`.
|
||||
# Mirror db_spend_update_writer to stay symmetric.
|
||||
_cache_creation_tokens = float(
|
||||
getattr(_pt_details, "cache_creation_tokens", 0)
|
||||
or getattr(_pt_details, "cache_write_tokens", 0)
|
||||
getattr(_pt_details, "cache_write_tokens", 0)
|
||||
or getattr(_pt_details, "cache_creation_tokens", 0)
|
||||
or 0
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -159,10 +159,13 @@ class DashScopeRerankConfig(BaseRerankConfig):
|
|||
model_response: RerankResponse,
|
||||
logging_obj: LiteLLMLoggingObj,
|
||||
api_key: Optional[str] = None,
|
||||
request_data: dict = {},
|
||||
optional_params: dict = {},
|
||||
litellm_params: dict = {},
|
||||
request_data: Optional[dict] = None,
|
||||
optional_params: Optional[dict] = None,
|
||||
litellm_params: Optional[dict] = None,
|
||||
) -> RerankResponse:
|
||||
request_data = request_data or {}
|
||||
optional_params = optional_params or {}
|
||||
litellm_params = litellm_params or {}
|
||||
try:
|
||||
response_json = raw_response.json()
|
||||
except Exception:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue