mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-05 07:37:50 +00:00
fix(openrouter): type embedding usage cost lookup
Annotate usage as a read-only mapping before looking up cost so the empty fallback does not introduce unknown member or variable types Signed-off-by: Viktor Oreshkin <solteke.st@gmail.com>
This commit is contained in:
parent
ce4465a11d
commit
1b960d3efe
1 changed files with 3 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ Docs: https://openrouter.ai/docs
|
|||
"""
|
||||
|
||||
import math
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, Final
|
||||
|
||||
import httpx
|
||||
|
|
@ -138,7 +139,8 @@ class OpenrouterEmbeddingConfig(BaseEmbeddingConfig):
|
|||
model_response_object=model_response,
|
||||
response_type="embedding",
|
||||
)
|
||||
response_cost: Final[object] = (response_json.get("usage") or {}).get("cost")
|
||||
usage: Final[Mapping[str, object]] = response_json.get("usage") or {}
|
||||
response_cost: Final = usage.get("cost")
|
||||
if (
|
||||
isinstance(response_cost, int | float)
|
||||
and not isinstance(response_cost, bool)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue