mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
style: ruff format the quality-signals cache changes
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
0100eed45d
commit
ac393aec7e
2 changed files with 8 additions and 16 deletions
|
|
@ -501,9 +501,7 @@ MAX_QUALITY_SIGNAL_ROWS: Final = 100_000
|
|||
|
||||
QUALITY_SIGNALS_CACHE_TTL_SECONDS: Final = 3600
|
||||
|
||||
_quality_signals_cache: Final = InMemoryCache(
|
||||
max_size_in_memory=64, default_ttl=QUALITY_SIGNALS_CACHE_TTL_SECONDS
|
||||
)
|
||||
_quality_signals_cache: Final = InMemoryCache(max_size_in_memory=64, default_ttl=QUALITY_SIGNALS_CACHE_TTL_SECONDS)
|
||||
|
||||
_QUALITY_SIGNALS_SQL: Final = """
|
||||
SELECT
|
||||
|
|
@ -564,7 +562,9 @@ def _quality_signals_for(
|
|||
if row.api_key not in reachable_by_key_dict:
|
||||
reachable_by_key_dict[row.api_key] = set()
|
||||
reachable_by_key_dict[row.api_key].add(row.model)
|
||||
reachable_by_key: Final = MappingProxyType({key: frozenset(models) for key, models in reachable_by_key_dict.items()})
|
||||
reachable_by_key: Final = MappingProxyType(
|
||||
{key: frozenset(models) for key, models in reachable_by_key_dict.items()}
|
||||
)
|
||||
reachable_models: Final = tuple(frozenset(row.model for row in router_key_rows))
|
||||
ranks: Final = rank_models_by_cost(llm_router, reachable_models) if llm_router is not None else MappingProxyType({})
|
||||
|
||||
|
|
|
|||
|
|
@ -567,9 +567,7 @@ class TestAutoRouterQualitySignals:
|
|||
assert err.value.status_code == 400
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_window_over_the_row_cap_is_rejected_not_silently_truncated(
|
||||
self, monkeypatch: pytest.MonkeyPatch
|
||||
):
|
||||
async def test_a_window_over_the_row_cap_is_rejected_not_silently_truncated(self, monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.proxy.management_endpoints.auto_router_endpoints import (
|
||||
MAX_QUALITY_SIGNAL_ROWS,
|
||||
)
|
||||
|
|
@ -705,9 +703,7 @@ class TestAutoRouterQualitySignals:
|
|||
assert response.totals.routed.abandonment_rate_pct == 50.0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_disconnect_before_first_token_is_excluded_from_abandonment(
|
||||
self, monkeypatch: pytest.MonkeyPatch
|
||||
):
|
||||
async def test_disconnect_before_first_token_is_excluded_from_abandonment(self, monkeypatch: pytest.MonkeyPatch):
|
||||
# Same shape as the test above, but the disconnect delivered nothing: the caller
|
||||
# never saw a response to judge, so it must not read as abandonment.
|
||||
rows = [
|
||||
|
|
@ -721,9 +717,7 @@ class TestAutoRouterQualitySignals:
|
|||
assert response.totals.routed.abandonment_rate_pct == 0.0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_repeated_window_is_served_from_cache_without_a_second_scan(
|
||||
self, monkeypatch: pytest.MonkeyPatch
|
||||
):
|
||||
async def test_a_repeated_window_is_served_from_cache_without_a_second_scan(self, monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.proxy import proxy_server
|
||||
from litellm.proxy.management_endpoints.auto_router_endpoints import (
|
||||
get_auto_router_quality_signals,
|
||||
|
|
@ -750,9 +744,7 @@ class TestAutoRouterQualitySignals:
|
|||
assert scans == 1
|
||||
assert second == first
|
||||
|
||||
await get_auto_router_quality_signals(
|
||||
user_api_key_dict=ADMIN, start_date="2026-08-01", end_date="2026-08-03"
|
||||
)
|
||||
await get_auto_router_quality_signals(user_api_key_dict=ADMIN, start_date="2026-08-01", end_date="2026-08-03")
|
||||
assert scans == 2
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue