The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(hermes_cli): micro-collapses in custom-provider save / lookup / token resolution
Teknium37821cd4bee2
diff --git a/hermes_cli/main_provider_setup.py b/hermes_cli/main_provider_setup.pyindex 76f35da38e7..08f4cad61bc 100644--- a/hermes_cli/main_provider_setup.py+++ b/hermes_cli/main_provider_setup.py@@ -438,7 +438,6 @@ def _save_custom_provider(base_url, api_key="", model="", context_length=None, nproviders = cfg.get("custom_providers") or []if not isinstance(providers, list):providers = []-for entry in providers:if not (isinstance(entry, dict) and entry.get("base_url", "").rstrip("/") == base_url.rstrip("/")):continue@@ -447,11 +446,7 @@ def _save_custom_provider(base_url, api_key="", model="", context_length=None, nentry["model"] = modelchanged = Trueif model and context_length:- models_cfg = entry.get("models", {})- if not isinstance(models_cfg, dict):- models_cfg = {}- models_cfg[model] = {"context_length": context_length}- entry["models"] = models_cfg+ _ensure_dict_section(entry, "models")[model] = {"context_length": context_length}changed = Trueif api_mode:if entry.get("api_mode") != api_mode:@@ -469,8 +464,7 @@ def _save_custom_provider(base_url, api_key="", model="", context_length=None, nsave_config(cfg)return # already saved, updated if needed- if not name:- name = _auto_provider_name(base_url)+ name = name or _auto_provider_name(base_url)entry = {"name": name, "base_url": base_url}if key_env:entry["key_env"] = key_env@@ -748,10 +742,7 @@ def _named_custom_provider_map(cfg) -> dict[str, dict[str, str]]:name_lc = str(name or "").strip().lower()pkey_lc = str(provider_key or "").strip().lower()model = str(model or "").strip()- for identity in ((pkey_lc, model), (pkey_lc,), (name_lc, model), (name_lc,)):- if identity[0] and identity in refs:- return refs[identity]- return ""+ return next((refs[i] for i in ((pkey_lc, model), (pkey_lc,), (name_lc, model), (name_lc,)) if i[0] and i in refs), "")custom_provider_map = {}for entry in get_compatible_custom_providers(cfg):diff --git a/hermes_cli/model_setup_flows.py b/hermes_cli/model_setup_flows.pyindex 8282e499632..13ef4b03b6c 100644--- a/hermes_cli/model_setup_flows.py+++ b/hermes_cli/model_setup_flows.py@@ -308,9 +308,7 @@ def _model_flow_nous(config, current_model="", args=None):# Portal URL is needed for upgrade links and the recommendations endpoints._nous_portal_url = ""with contextlib.suppress(Exception):- _nous_state = get_provider_auth_state("nous")- if _nous_state:- _nous_portal_url = _nous_state.get("portal_base_url", "")+ _nous_portal_url = (get_provider_auth_state("nous") or {}).get("portal_base_url", "")catalog = _nous_model_catalog(free_tier, _nous_portal_url, model_ids, pricing)if catalog is None:@@ -352,8 +350,7 @@ def _model_flow_openai_codex(config, current_model=""):_codex_token = Nonewith contextlib.suppress(Exception):_codex_status = get_codex_auth_status()- if _codex_status.get("logged_in"):- _codex_token = _codex_status.get("api_key")+ _codex_token = _codex_status.get("api_key") if _codex_status.get("logged_in") else Noneif not _codex_token:with contextlib.suppress(Exception):from hermes_cli.auth import resolve_codex_runtime_credentials