mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-24 00:52:24 +00:00
test(prism): derive the asserted model list from the cost map instead of pinning it
This commit is contained in:
parent
120883f9f8
commit
35becf7f3a
1 changed files with 9 additions and 22 deletions
|
|
@ -51,25 +51,11 @@ def test_prism_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPat
|
|||
assert api_base == "https://prism.internal.example/v1"
|
||||
|
||||
|
||||
PRISM_CATALOG_SNAPSHOT = (
|
||||
"per GET https://api.prisminference.com/v1/models on 2026-09-19; "
|
||||
"a mismatch means the catalog moved, not that cost tracking broke"
|
||||
)
|
||||
PRISM_MODELS = tuple(sorted(name for name in litellm.model_cost if name.startswith("prism/")))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("model", "usd_per_million_input", "usd_per_million_output", "supports_vision"),
|
||||
[
|
||||
("prism/deepseek-v4.1-flash", 0.17, 0.63, True),
|
||||
("prism/deepseek-v4-flash", 0.17, 0.21, False),
|
||||
],
|
||||
)
|
||||
def test_prism_model_cost_and_capabilities(
|
||||
model: str,
|
||||
usd_per_million_input: float,
|
||||
usd_per_million_output: float,
|
||||
supports_vision: bool,
|
||||
):
|
||||
@pytest.mark.parametrize("model", PRISM_MODELS)
|
||||
def test_prism_model_cost_and_capabilities(model: str):
|
||||
from litellm.cost_calculator import cost_per_token
|
||||
|
||||
prompt_cost, completion_cost = cost_per_token(
|
||||
|
|
@ -82,17 +68,16 @@ def test_prism_model_cost_and_capabilities(
|
|||
|
||||
assert prompt_cost == pytest.approx(model_info["input_cost_per_token"] * 1_000_000)
|
||||
assert completion_cost == pytest.approx(model_info["output_cost_per_token"] * 1_000_000)
|
||||
assert (prompt_cost, completion_cost) == pytest.approx(
|
||||
(usd_per_million_input, usd_per_million_output)
|
||||
), PRISM_CATALOG_SNAPSHOT
|
||||
assert 0 < model_info["cache_read_input_token_cost"] < model_info["input_cost_per_token"]
|
||||
assert model_info["output_cost_per_token"] > 0
|
||||
assert model_info["max_tokens"] == model_info["max_output_tokens"] <= model_info["max_input_tokens"]
|
||||
assert model_info["litellm_provider"] == "prism"
|
||||
assert model_info["mode"] == "chat"
|
||||
assert model_info["supports_function_calling"] is True
|
||||
assert model_info["supports_native_streaming"] is True
|
||||
assert model_info["supports_reasoning"] is True
|
||||
assert model_info["supports_response_schema"] is True
|
||||
assert litellm.supports_vision(model) is model_info["supports_vision"]
|
||||
assert model_info["supports_vision"] is supports_vision, PRISM_CATALOG_SNAPSHOT
|
||||
|
||||
|
||||
def test_prism_backup_registry_mirrors_cost_map():
|
||||
|
|
@ -101,7 +86,9 @@ def test_prism_backup_registry_mirrors_cost_map():
|
|||
backup = json.loads((package_root / "model_prices_and_context_window_backup.json").read_text())
|
||||
prism_entries = {name: entry for name, entry in cost_map.items() if name.startswith("prism/")}
|
||||
|
||||
assert set(prism_entries) == {"prism/deepseek-v4.1-flash", "prism/deepseek-v4-flash"}
|
||||
assert tuple(sorted(prism_entries)) == PRISM_MODELS
|
||||
assert prism_entries
|
||||
assert all("supports_vision" in entry for entry in prism_entries.values())
|
||||
assert prism_entries == {name: backup[name] for name in prism_entries}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue