mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
Merge bdada02d47 into 02035120e4
This commit is contained in:
commit
a4ada4cb1b
2 changed files with 26 additions and 1 deletions
|
|
@ -12632,7 +12632,7 @@ def _enrich_model_info_with_litellm_data(
|
|||
except Exception:
|
||||
litellm_model_info = {}
|
||||
for k, v in litellm_model_info.items():
|
||||
if k not in model_info:
|
||||
if model_info.get(k) is None:
|
||||
model_info[k] = v
|
||||
model["model_info"] = model_info
|
||||
# don't return the api key / vertex credentials
|
||||
|
|
|
|||
|
|
@ -69,6 +69,31 @@ def test_v2_model_info_in_openapi_schema():
|
|||
assert "get" in schema["paths"]["/v2/model/info"]
|
||||
|
||||
|
||||
def test_v2_model_info_enrichment_heals_none_valued_cost_keys():
|
||||
"""A deployment that has served a request carries its cost keys as explicit None, because
|
||||
Deployment materialises every unset ModelInfo field. Backfilling only absent keys left those
|
||||
None values unhealed, so this route reported no pricing for exactly the models in use."""
|
||||
from litellm.proxy.proxy_server import _enrich_model_info_with_litellm_data
|
||||
|
||||
base = {
|
||||
"model_name": "claude-haiku-4-5",
|
||||
"litellm_params": {"model": "anthropic/claude-haiku-4-5-20251001"},
|
||||
}
|
||||
|
||||
absent = _enrich_model_info_with_litellm_data(model={**base, "model_info": {"id": "abc"}})
|
||||
expected = absent["model_info"]["input_cost_per_token"]
|
||||
assert expected is not None
|
||||
|
||||
served = _enrich_model_info_with_litellm_data(
|
||||
model={
|
||||
**base,
|
||||
"model_info": {"id": "abc", "input_cost_per_token": None, "output_cost_per_token": None},
|
||||
}
|
||||
)
|
||||
assert served["model_info"]["input_cost_per_token"] == expected
|
||||
assert served["model_info"]["output_cost_per_token"] is not None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# GET /v1/model/info, GET /model/info
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue