a74e76632c
_nous_picker_model_ids only uses the ids the Portal unions append — both
unions discard the pricing map (`model_ids, _ = union_with_portal_*`) — yet
it called get_pricing_for_provider("nous") without cached_only, so a cold
pricing cache paid a full /v1/models round-trip (network timeout on a slow
Portal) on the picker-open path for nothing. Pass cached_only=True; the
background pricing prewarm (#101685) fills the same cache for later opens.
Re-derived from #102099 by @finn763: the original patched
hermes_cli/model_switch.py, which 3b1ecfc0a1 decomposed; the live call site is
hermes_cli/model_switch_providers.py.
Based on #102099 by @finn763.
23 lines
1.0 KiB
Python
23 lines
1.0 KiB
Python
"""The Nous picker row never starts a pricing fetch: the picker only uses the ids the Portal
|
|
unions append, and a cold pricing cache must not hold the picker open (salvage of #102099)."""
|
|
|
|
import hermes_cli.models_pricing as mp
|
|
from hermes_cli import model_switch_providers as msp
|
|
|
|
|
|
def test_nous_picker_model_ids_reads_pricing_cache_only(monkeypatch):
|
|
seen: list[bool] = []
|
|
|
|
def fake_pricing(provider, *, force_refresh=False, cached_only=False):
|
|
seen.append(cached_only)
|
|
return {}
|
|
|
|
monkeypatch.setattr(mp, "get_pricing_for_provider", fake_pricing)
|
|
# Keep the sibling Portal calls off the network; only the pricing call shape is under test.
|
|
monkeypatch.setattr("hermes_cli.models.check_nous_free_tier", lambda **kw: False)
|
|
monkeypatch.setattr("hermes_cli.models.fetch_nous_recommended_models", lambda *a, **kw: None)
|
|
monkeypatch.setattr(mp, "nous_policy_allowed_ids", lambda **kw: None)
|
|
|
|
assert msp._nous_picker_model_ids({"nous": ["nous/a"]}, False) == ["nous/a"]
|
|
assert seen == [True]
|