mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-22 18:30:28 +00:00
2ca220eec0
PR #1970 added a dedicated `elif pid == "lmstudio":` branch in `get_available_models()` that fetches the live /v1/models list when the hermes_cli helper doesn't have ids cached. The fallback path inside that branch only looked at `cfg["providers"]["lmstudio"]["base_url"]`, missing the historical config shape where the URL lives under `cfg["model"]`: model: provider: lmstudio base_url: http://192.168.1.22:1234/v1 ← here, not under providers.lmstudio providers: lmstudio: api_key: local-key 3 pre-existing tests in tests/test_issue1527_lmstudio_base_url_classification broke on stage-337 because of this — they passed on master, failed after the PR #1970 merge. The simpler fix is to enhance the already-introduced `_get_provider_base_url()` helper so it falls back to `cfg["model"]["base_url"]` when `cfg["model"]["provider"] == provider_id`, then use the helper inside the lmstudio branch instead of a direct lookup. This keeps the previous behaviour (where the generic configured-provider branch handled lmstudio via the model block) while preserving PR #1970's live-discovery additions. Belt-and-suspenders: `_get_provider_base_url()` explicitly does NOT inherit model.base_url for providers other than the active one — if a user's config says `model.provider: anthropic` and they have `providers.openai` configured without a base_url, openai must still resolve to None (use SDK default), not to the anthropic proxy URL. 6 new regression tests in tests/test_pr1970_lmstudio_base_url_fallback.py lock the two-location lookup, the precedence rule (explicit providers entry wins over model fallback), trailing-slash stripping, and the negative case (model.base_url MUST NOT leak to non-active providers). All 51 tests in the existing model-resolver + custom-provider banks still pass. Caught by maintainer review on stage-337 (full pytest with the new network isolation in place surfaced the regression that the fork-CI mock-server path would have hidden).