fix: guard validate_requested_model + expand test coverage (PR #649 follow-up)

- Wrap validate_requested_model in try/except so /model doesn't crash
  if validation itself fails (falls back to old accept+save behavior)
- Remove unnecessary sys.path.insert from both test files
- Expand test_model_validation.py: 4 → 23 tests covering normalize_provider,
  provider_model_ids, empty/whitespace/spaces rejection, OpenRouter format
  validation, custom endpoints, nous provider, provider aliases, unknown
  providers, fuzzy suggestions
- Expand test_cli_model_command.py: 2 → 5 tests adding known-model save,
  validation crash fallback, and /model with no argument
This commit is contained in:
teknium1 2026-03-08 04:47:31 -07:00
parent 9d3a44e0e8
commit 90fa9e54ca
3 changed files with 190 additions and 25 deletions

14
cli.py
View file

@ -2034,11 +2034,15 @@ class HermesCLI:
except Exception:
provider_for_validation = self.provider or self.requested_provider
validation = validate_requested_model(
new_model,
provider_for_validation,
base_url=self.base_url,
)
try:
validation = validate_requested_model(
new_model,
provider_for_validation,
base_url=self.base_url,
)
except Exception:
# Validation itself failed — fall back to old behavior (accept + save)
validation = {"accepted": True, "persist": True, "recognized": False, "message": None}
if not validation.get("accepted"):
print(f"(^_^) Warning: {validation.get('message')}")