refactor(cost): drop the docstrings that restate TokenRates and the new tests

This commit is contained in:
mateo-berri 2026-09-03 15:37:56 -07:00
parent 8e4397d5f1
commit 24531ee576
3 changed files with 0 additions and 23 deletions

View file

@ -417,11 +417,6 @@ def _is_off_peak(off_peak: Mapping[str, object], current_time: datetime | None =
@dataclass(frozen=True, slots=True)
class TokenRates:
"""The per-token rates one request bills at. reasoning_rate is None when reasoning bills at
output_rate: the model has no dedicated reasoning rate, or the caller resolves reasoning on
its own.
"""
input_rate: float
output_rate: float
cache_read_rate: float

View file

@ -815,8 +815,6 @@ def _off_peak_reasoning_usage() -> Usage:
def test_generic_cost_per_token_off_peak_reasoning_rate():
"""Regression (LIT-6887): the block's output_cost_per_reasoning_token used to be ignored, so
reasoning tokens billed at the model's standard reasoning rate all through the window."""
from datetime import datetime, timezone
model_name = "litellm-test-off-peak-reasoning"
@ -843,8 +841,6 @@ def test_generic_cost_per_token_off_peak_reasoning_rate():
def test_generic_cost_per_token_off_peak_block_without_reasoning_rate():
"""A block that leaves output_cost_per_reasoning_token unset keeps the model's own reasoning
rate, and a model with no reasoning rate at all follows the off-peak output rate."""
from datetime import datetime, timezone
inside_window = datetime(2026, 1, 1, 18, 0, tzinfo=timezone.utc)
@ -870,7 +866,6 @@ def test_generic_cost_per_token_off_peak_block_without_reasoning_rate():
def test_generic_cost_per_token_off_peak_reasoning_rate_wins_over_the_tier():
"""Tiered models resolve reasoning on their own path, so the block has to win there too."""
from datetime import datetime, timezone
model_name = "litellm-test-off-peak-tiered-reasoning"
@ -914,8 +909,6 @@ def test_generic_cost_per_token_off_peak_reasoning_rate_wins_over_the_tier():
def test_generic_cost_per_token_off_peak_reasoning_rate_wins_over_the_service_tier():
"""A priority request bills its service-tier reasoning rate outside the window and the block's
rate inside it."""
from datetime import datetime, timezone
model_name = "litellm-test-off-peak-reasoning-service-tier"
@ -946,7 +939,6 @@ def test_generic_cost_per_token_off_peak_reasoning_rate_wins_over_the_service_ti
def test_apply_off_peak_pricing_treats_bool_as_unset_and_parses_strings():
"""A YAML true never turns into a rate of 1.0, and a quoted number still counts."""
from datetime import datetime, timezone
model_name = "litellm-test-off-peak-odd-values"
@ -972,9 +964,6 @@ def test_apply_off_peak_pricing_treats_bool_as_unset_and_parses_strings():
def test_get_token_base_cost_off_peak_cache_creation_rate():
"""Regression (LIT-6887): the block's cache_creation_input_token_cost used to be ignored. It
replaces the five-minute cache-creation rate inside the window; the one-hour rate, and a
block without the key, keep the standard rate."""
from datetime import datetime, timezone
from typing import cast
@ -1008,8 +997,6 @@ def test_get_token_base_cost_off_peak_cache_creation_rate():
def test_get_token_type_cost_breakdown_reflects_off_peak_reasoning_and_cache_creation_rates():
"""The per-token-type breakdown feeds the spend logs, so it has to bill the new keys the same
way the total does."""
from datetime import datetime, timezone
model_name = "litellm-test-off-peak-breakdown"

View file

@ -650,8 +650,6 @@ class TestDashscopeCostCalculator:
assert math.isclose(completion_cost, 200 * 2.4e-06, rel_tol=1e-10)
def test_dashscope_off_peak_reasoning_rate_replaces_the_dedicated_reasoning_rate(self):
"""Regression (LIT-6887): a block carrying output_cost_per_reasoning_token bills reasoning
tokens at it inside the window, over the model's own reasoning rate, which returns outside."""
self._register_off_peak_flat_model(
"dashscope/qwen-reasoning-rate-off-peak-test",
{
@ -678,8 +676,6 @@ class TestDashscopeCostCalculator:
assert math.isclose(peak_completion_cost, (150 * 4.8e-06) + (50 * 9e-06), rel_tol=1e-10)
def test_dashscope_off_peak_cache_creation_rate_replaces_the_standard_rate(self):
"""Regression (LIT-6887): a block carrying cache_creation_input_token_cost bills cache-creation
tokens at it inside the window, while the cache-read rate it leaves unset stays standard."""
self._register_off_peak_flat_model(
"dashscope/qwen-cache-creation-off-peak-test",
{"hours_utc": self.OFF_PEAK_WINDOW, "cache_creation_input_token_cost": 1.5e-06},
@ -701,7 +697,6 @@ class TestDashscopeCostCalculator:
assert math.isclose(peak_prompt_cost, (600 * 2.4e-06) + (300 * 2e-07) + (100 * 3e-06), rel_tol=1e-10)
def test_dashscope_off_peak_reasoning_and_cache_creation_rates_override_the_selected_tier(self):
"""The new keys override the selected tier the way the input and output rates already do."""
self._register_tiered_model(
"dashscope/qwen-tiered-reasoning-off-peak-test",
[