HERMES-GIELIE/api
bergeouss cd01e4d5ba
feat(models): live-first model fetching for all OpenAI-compat providers (#892)
* feat(models): live-first model fetching for all OpenAI-compat providers (#871)

The WebUI model picker relied on hardcoded _PROVIDER_MODELS as primary
source for providers like zai, minimax, mistralai, xai, openai-codex,
deepseek, and gemini. These lists go stale — new models don't appear
until someone manually updates the dict.

Add an OpenAI-compat /v1/models fetch fallback in _handle_live_models()
that fires when provider_model_ids() is unavailable or returns []. The
resolution chain is now:

  1. hermes_cli.provider_model_ids() (agent's live fetch)
  2. Custom providers from config.yaml
  3. Direct /v1/models fetch for known OpenAI-compat endpoints
  4. Static _PROVIDER_MODELS as last-resort offline fallback

Covers: zai, minimax, mistralai, xai, openai-codex, deepseek, gemini.

Uses urllib (stdlib) — no new dependencies. Static lists remain as
offline fallback so the UI always shows something.

Closes #871

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* refactor(models): address review feedback on live fetch (#892)

Five changes from nesquena-hermes review:

1. Move _OPENAI_COMPAT_ENDPOINTS to module level — avoid dict
   reconstruction per request
2. Document urllib blocking behavior — 8s timeout acceptable because
   server is threaded and frontend enriches in background
3. Add TODO comment for TTL-based caching follow-up
4. Remove openai-codex from endpoint map — same endpoint as base
   openai provider, already covered by provider_model_ids()
5. Restrict API key lookup to provider-scoped and model.api_key only
   — remove top-level api_key fallback to prevent cross-provider
   key leakage

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 09:45:46 -07:00
..
__init__.py
auth.py release: v0.50.102–v0.50.108 batch (code blocks, utf-8, image URLs, deletion warning, PermissionError, Docker docs, kimi-k2.5) (#755) 2026-04-20 00:26:55 -07:00
clarify.py feat: harden clarify dialog flow and refresh recovery 2026-04-15 13:10:50 +08:00
commands.py feat: slash command parity + skill autocomplete — v0.50.91 (PR #711) 2026-04-19 05:37:44 +00:00
config.py fix: Nous static models use @nous: prefix — v0.50.164 (#885) 2026-04-22 22:56:21 -07:00
gateway_watcher.py fix(sessions): surface gateway SSE failures and add polling fallback (#828) 2026-04-21 21:18:55 -07:00
helpers.py fix: correct webui profile switching state — v0.50.150 (PR #849 by @migueltavares) 2026-04-22 16:27:01 +00:00
models.py feat(ui): session attention indicators — streaming spinner, unread dot, timestamps (#856) 2026-04-23 09:05:57 -07:00
onboarding.py fix(onboarding): recognize credential_pool OAuth auth for openai-codex (#797) 2026-04-21 15:41:34 +00:00
profiles.py fix(profiles): complete profile isolation via cookie + thread-local (#805) 2026-04-21 17:04:11 +00:00
providers.py fix(ci): eliminate test_set_key flakiness — v0.50.161 2026-04-23 02:09:37 +00:00
routes.py feat(models): live-first model fetching for all OpenAI-compat providers (#892) 2026-04-23 09:45:46 -07:00
session_ops.py feat: slash command parity + skill autocomplete — v0.50.91 (PR #711) 2026-04-19 05:37:44 +00:00
startup.py fix(security): gate auto-install behind HERMES_WEBUI_AUTO_INSTALL=1 — v0.50.156 2026-04-22 20:49:28 +00:00
state_sync.py security: bandit fixes B310/B324/B110 + QuietHTTPServer (#354) 2026-04-13 11:11:56 -07:00
streaming.py fix: remove hardcoded chinese title heuristics (#887) 2026-04-23 09:45:34 -07:00
updates.py fix: update banner — conflict recovery path + server self-restart after update (#816) 2026-04-21 17:10:41 -07:00
upload.py v0.50.25: mobile scroll, import timestamps, profile security, mic fallback (#404) 2026-04-13 22:11:45 -07:00
workspace.py feat(workspaces): autocomplete trusted workspace paths — v0.50.162 (PR #880 by @franksong2702, closes #616) 2026-04-23 02:35:58 +00:00