fix(anthropic): live model fetching + adaptive thinking for 4.5+ models

- Add _fetch_anthropic_models() to hermes_cli/models.py — hits the
  Anthropic /v1/models endpoint to get the live model catalog. Handles
  both API key and OAuth token auth headers.

- Wire it into provider_model_ids() so both 'hermes model' and
  'hermes setup model' show the live list instead of a stale static one.

- Update static _PROVIDER_MODELS fallback with full current catalog:
  opus-4-6, sonnet-4-6, opus-4-5, sonnet-4-5, opus-4, sonnet-4, haiku-4-5

- Update model_metadata.py with context lengths for all current models.

- Fix thinking parameter for 4.5+ models: use type='adaptive' instead
  of type='enabled' (Anthropic deprecated 'enabled' for newer models,
  warns at runtime). Detects model version from the model name string.

Verified live:
  hermes model → Anthropic → auto-detected creds → shows 7 live models
  hermes chat --provider anthropic --model claude-opus-4-6 → works
This commit is contained in:
teknium1
2026-03-12 17:04:31 -07:00
parent d51243b6d3
commit cd4e995d54
4 changed files with 67 additions and 5 deletions

View File

@@ -1229,9 +1229,12 @@ def setup_model_provider(config: dict):
_set_default_model(config, custom)
# else: keep current
elif selected_provider == "anthropic":
anthropic_models = [
"claude-sonnet-4-20250514",
"claude-opus-4-20250514",
# Try live model list first, fall back to static
from hermes_cli.models import provider_model_ids
live_models = provider_model_ids("anthropic")
anthropic_models = live_models if live_models else [
"claude-opus-4-6",
"claude-sonnet-4-6",
"claude-haiku-4-5-20251001",
]
model_choices = list(anthropic_models)