fix(web_server): persist full model list from Test, key_env for Desktop, IP guard - #69488
fix(web_server): persist full model list from Test, key_env for Desktop, IP guard#69488asorry75 wants to merge 1 commit into
Conversation
|
To clarify the relationship with #57557: #57557 fixes the CLI path (hermes model command, model_setup_flows.py + main.py) These are two completely separate code paths that both write custom endpoint config. #57557 does not cover the Desktop UI flow — the Desktop Custom Endpoints panel still writes the raw API key to config.yaml. |
28877b8 to
6a33e65
Compare
6a33e65 to
8fc2782
Compare
…op, IP guard Fixes NousResearch#69449, Fixes NousResearch#69988 - CustomEndpointUpdate: add optional models field for frontend discovery - _write_custom_endpoint: backend probe /v1/models on Save when body.models is empty and discovery is enabled, persisting the full model list to config.yaml - _detach_main_model_from_provider: clean up key_env on endpoint delete - key_env derivation: guard against raw-IP hostnames (127.0.0.1) by prepending HERMES_CUSTOM_ when the derived name starts with a digit - Frontend: handleSave passes discoveredModels to Save API - Frontend types: CustomEndpointUpdate includes models field
65cf52a to
4011c6a
Compare
|
Thanks @asorry75 — your root-cause analysis on both #69449 and #69988 was spot on, and three specific things from this PR are in the replacement: the Closing in favour of #71141, which credits you as a co-author. Two reasons it needed rebuilding rather than merging: The branch was based on an older The other change is that the backend re-probe on Save isn't needed — the panel's |
Fixes #69449, Fixes #69988
Changes
This PR addresses three issues related to custom provider configuration:
1. #69449 — Plaintext API key storage for Desktop custom endpoints
Store the API key in
.envviasave_env_value()and keep onlykey_envin config.yaml. This is the Desktop UI counterpart to #57557 (liuhao1024's CLI path fix).2. #69988 — Custom provider model list only persists one model
Problem: After configuring a third-party provider, the Test button correctly discovers N models ("Found N models"). However, clicking Save only persists the single model name the user typed manually. All downstream views (main model picker, auxiliary picker, chat composer) show only 1 model.
Root cause:
_write_custom_endpointupserts only the user-typed model intoentry["models"];toPayload()does not passdiscoveredModelsto the Save request.Fix:
models: Optional[List[str]] = NonetoCustomEndpointUpdateso the frontend can pass discovered modelsbody.modelsis empty (frontend didn't send them, or older UI), the backend probes/v1/modelsitself during Save and persists the full model listlen(models_map) <= 1(first-time configuration), avoiding unnecessary HTTP calls on subsequent edits. This logic's responsibility is "complete the model list on first save", not "sync the model catalog" (the latter belongs tomodel_switch.py's probe duty)key_envcleanup in_detach_main_model_from_providerso deleting an endpoint also removes stale env var referencesKnown UI limitation: The settings panel uses
<datalist>for the model field, which doesn't expand all options when the field has a value. Suggest replacing with<select>or dropdown+manual-entry hybrid in a future update. The backend fix ensures all terminals show the full model list after Save regardless.3. key_env compatibility with raw IP addresses
When base_url is a raw IP (e.g.
http://127.0.0.1:8000/v1), hostname derivation produces an invalid env var name (127_0_0_1_API_KEYstarts with a digit). Added a guard that prependsHERMES_CUSTOM_when the derived name starts with a digit.This extends liuhao1024's key_env approach from #57557 to the Desktop path (#69488), with an additional edge case fix for IP-based URLs.
Files Changed
hermes_cli/web_server.pymodelsfield toCustomEndpointUpdate, backend model probe on Save,key_envcleanup on delete, IP-prefix guardapps/desktop/src/types/hermes.tsmodels?: string[]toCustomEndpointUpdateinterfaceapps/desktop/src/app/settings/custom-endpoints-settings.tsxhandleSave()passesdiscoveredModelsto Save APITest Results
pytest -k custom_endpoint: 4 passed, 2 failed. The 2 remaining failures are expected after the key_env migration — tests still assertmodel_cfg.get("api_key")returns plaintext, but the value now lives in.env. Test updates are outside this PR's scope.config.yamlhas 4 models → chat composer, main model picker, and auxiliary picker all show 4 models.Acknowledgements