fix(nous): use curated model list instead of full API dump for Nous Portal (#3867)
All three Nous Portal model selection paths (hermes model, first-time login, setup wizard) were hitting the live /models endpoint and showing every model available — potentially hundreds. Now uses the curated _PROVIDER_MODELS['nous'] list (25 agentic models matching OpenRouter defaults) with 'Enter custom model name' for anything else. Fixed in: - hermes_cli/main.py: _model_flow_nous() - hermes_cli/auth.py: _login_nous() model selection - hermes_cli/setup.py: post-login model selection
This commit is contained in:
+6
-7
@@ -2310,21 +2310,20 @@ def _login_nous(args, pconfig: ProviderConfig) -> None:
|
|||||||
raise AuthError("No runtime API key available to fetch models",
|
raise AuthError("No runtime API key available to fetch models",
|
||||||
provider="nous", code="invalid_token")
|
provider="nous", code="invalid_token")
|
||||||
|
|
||||||
model_ids = fetch_nous_models(
|
# Use curated model list (same as OpenRouter defaults) instead
|
||||||
inference_base_url=runtime_base_url,
|
# of the full /models dump which returns hundreds of models.
|
||||||
api_key=runtime_key,
|
from hermes_cli.models import _PROVIDER_MODELS
|
||||||
timeout_seconds=timeout_seconds,
|
model_ids = _PROVIDER_MODELS.get("nous", [])
|
||||||
verify=verify,
|
|
||||||
)
|
|
||||||
|
|
||||||
print()
|
print()
|
||||||
if model_ids:
|
if model_ids:
|
||||||
|
print(f"Showing {len(model_ids)} curated models — use \"Enter custom model name\" for others.")
|
||||||
selected_model = _prompt_model_selection(model_ids)
|
selected_model = _prompt_model_selection(model_ids)
|
||||||
if selected_model:
|
if selected_model:
|
||||||
_save_model_choice(selected_model)
|
_save_model_choice(selected_model)
|
||||||
print(f"Default model set to: {selected_model}")
|
print(f"Default model set to: {selected_model}")
|
||||||
else:
|
else:
|
||||||
print("No models were returned by the inference API.")
|
print("No curated models available for Nous Portal.")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
message = format_auth_error(exc) if isinstance(exc, AuthError) else str(exc)
|
message = format_auth_error(exc) if isinstance(exc, AuthError) else str(exc)
|
||||||
print()
|
print()
|
||||||
|
|||||||
+13
-11
@@ -1084,14 +1084,20 @@ def _model_flow_nous(config, current_model=""):
|
|||||||
# login_nous already handles model selection + config update
|
# login_nous already handles model selection + config update
|
||||||
return
|
return
|
||||||
|
|
||||||
# Already logged in — fetch models and select
|
# Already logged in — use curated model list (same as OpenRouter defaults).
|
||||||
print("Fetching models from Nous Portal...")
|
# The live /models endpoint returns hundreds of models; the curated list
|
||||||
|
# shows only agentic models users recognize from OpenRouter.
|
||||||
|
from hermes_cli.models import _PROVIDER_MODELS
|
||||||
|
model_ids = _PROVIDER_MODELS.get("nous", [])
|
||||||
|
if not model_ids:
|
||||||
|
print("No curated models available for Nous Portal.")
|
||||||
|
return
|
||||||
|
|
||||||
|
print(f"Showing {len(model_ids)} curated models — use \"Enter custom model name\" for others.")
|
||||||
|
|
||||||
|
# Verify credentials are still valid (catches expired sessions early)
|
||||||
try:
|
try:
|
||||||
creds = resolve_nous_runtime_credentials(min_key_ttl_seconds=5 * 60)
|
creds = resolve_nous_runtime_credentials(min_key_ttl_seconds=5 * 60)
|
||||||
model_ids = fetch_nous_models(
|
|
||||||
inference_base_url=creds.get("base_url", ""),
|
|
||||||
api_key=creds.get("api_key", ""),
|
|
||||||
)
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
relogin = isinstance(exc, AuthError) and exc.relogin_required
|
relogin = isinstance(exc, AuthError) and exc.relogin_required
|
||||||
msg = format_auth_error(exc) if isinstance(exc, AuthError) else str(exc)
|
msg = format_auth_error(exc) if isinstance(exc, AuthError) else str(exc)
|
||||||
@@ -1108,11 +1114,7 @@ def _model_flow_nous(config, current_model=""):
|
|||||||
except Exception as login_exc:
|
except Exception as login_exc:
|
||||||
print(f"Re-login failed: {login_exc}")
|
print(f"Re-login failed: {login_exc}")
|
||||||
return
|
return
|
||||||
print(f"Could not fetch models: {msg}")
|
print(f"Could not verify credentials: {msg}")
|
||||||
return
|
|
||||||
|
|
||||||
if not model_ids:
|
|
||||||
print("No models returned by the inference API.")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
selected = _prompt_model_selection(model_ids, current_model=current_model)
|
selected = _prompt_model_selection(model_ids, current_model=current_model)
|
||||||
|
|||||||
+3
-4
@@ -1002,10 +1002,9 @@ def setup_model_provider(config: dict):
|
|||||||
min_key_ttl_seconds=5 * 60,
|
min_key_ttl_seconds=5 * 60,
|
||||||
timeout_seconds=15.0,
|
timeout_seconds=15.0,
|
||||||
)
|
)
|
||||||
nous_models = fetch_nous_models(
|
# Use curated model list instead of full /models dump
|
||||||
inference_base_url=creds.get("base_url", ""),
|
from hermes_cli.models import _PROVIDER_MODELS
|
||||||
api_key=creds.get("api_key", ""),
|
nous_models = _PROVIDER_MODELS.get("nous", [])
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug("Could not fetch Nous models after login: %s", e)
|
logger.debug("Could not fetch Nous models after login: %s", e)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user