refactor(models): import openrouter_variant_base from its defining module

Internal moves get no re-export aliases: models_validate reads
hermes_constants.openrouter_variant_base directly and the private
_OPENROUTER_VARIANT_SUFFIXES/_openrouter_variant_base shims are dropped.
This commit is contained in:
Teknium
2026-09-11 16:27:53 -07:00
parent f28c52845a
commit 30e4673776
3 changed files with 3 additions and 19 deletions
-9
View File
@@ -39,7 +39,6 @@ from hermes_cli.models_catalog_static import (
_LIVE_FIRST_PICKER_PROVIDERS,
_MODELS_DEV_PREFERRED,
_OPENAI_FAST_MODE_PREFIXES,
_OPENROUTER_VARIANT_SUFFIXES,
_PROVIDER_ALIASES,
_PROVIDER_LABELS,
_PROVIDER_MODELS,
@@ -60,7 +59,6 @@ from hermes_cli.models_local import (
_ollama_probe_cache_key,
_root_for_ollama_native_api,
fetch_ollama_cloud_models)
from hermes_constants import OPENROUTER_VARIANT_SUFFIXES, openrouter_variant_base
logger = logging.getLogger(__name__)
@@ -839,13 +837,6 @@ def _model_in_provider_catalog(name_lower: str, providers: set[str]) -> bool:
for model in _provider_catalog_names(provider))
# Canonical suffix set lives in ``hermes_constants`` so the metadata layer can
# share it without importing the CLI. Re-exported here under the historical
# private names used by ``validate_requested_model``.
_OPENROUTER_VARIANT_SUFFIXES = OPENROUTER_VARIANT_SUFFIXES
_openrouter_variant_base = openrouter_variant_base
def _resolve_static_model_alias(
name_lower: str, current_keys: set[str]) -> Optional[tuple[str, str]]:
"""Resolve short aliases (e.g. sonnet/opus) using static catalogs only."""
-8
View File
@@ -8,8 +8,6 @@ from __future__ import annotations
from typing import NamedTuple
from hermes_constants import OPENROUTER_VARIANT_SUFFIXES
# Fallback OpenRouter snapshot used when the live catalog is unavailable, as
# ``(model_id, description shown in menus)``. ``:free`` SKUs are described "free".
@@ -508,12 +506,6 @@ _PROVIDER_RETIRED_ALIASES: dict[str, tuple[str, ...]] = {
_AGGREGATOR_PROVIDERS = frozenset({"nous", "openrouter", "ai-gateway", "copilot", "kilocode"})
# Canonical suffix set lives in ``hermes_constants`` so the metadata layer can
# share it without importing the CLI. Re-exported here under the historical
# private name used by ``hermes_cli.models``.
_OPENROUTER_VARIANT_SUFFIXES = OPENROUTER_VARIANT_SUFFIXES
# Subscription/OAuth providers whose catalogs RE-EXPOSE other vendors' models; tried only as a last
# resort for bare short-alias resolution (after every native-vendor catalog) so they never hijack
# an alias from the model's native vendor. None currently defined.
+3 -2
View File
@@ -16,6 +16,7 @@ from difflib import get_close_matches
from typing import Any, Callable, Optional
from utils import base_url_host_matches
from hermes_constants import openrouter_variant_base
# ── Verdicts ─────────────────────────────────────────────────────────────
@@ -433,7 +434,7 @@ def _validate_live_listing(req: _Request) -> Optional[dict[str, Any]]:
# catalog entries — validate the BASE but keep the suffixed id. Must run BEFORE fuzzy
# auto-correction, which would otherwise "correct" `model:nitro` → `model` and silently
# strip the routing opt-in.
variant_base = _m._openrouter_variant_base(req.lookup) if req.normalized == "openrouter" else None
variant_base = openrouter_variant_base(req.lookup) if req.normalized == "openrouter" else None
if variant_base is not None and variant_base in set(api_models):
return _accept()
# Listed but not found: the account may reach models absent from the public listing
@@ -502,7 +503,7 @@ def _validate_catalog_fallback(req: _Request) -> dict[str, Any]:
return _accept()
# Same OpenRouter routing-variant rule as the live-listing path.
if req.normalized == "openrouter":
variant_base = _m._openrouter_variant_base(req.lookup)
variant_base = openrouter_variant_base(req.lookup)
if variant_base is not None and variant_base.lower() in {m.lower() for m in catalog}:
return _accept()
return match.verdict(req, keep_suffix=True) or _soft_accept(