perf(cli): cap /model picker custom-endpoint probe at 1.5s
The interactive /model picker probes the current custom endpoint live via fetch_api_models(), which defaults to a 5s timeout. A slow or flaky custom endpoint blocks the picker for up to 5s on open. The lmstudio picker probe already uses a 1.5s timeout for exactly this reason; apply the same fast-fail bound to the three custom-provider probe sites, gated on for_picker so the non-picker (5s) path is unchanged.
This commit is contained in:
@@ -2702,6 +2702,7 @@ def list_authenticated_providers(
|
||||
live_models = fetch_api_models(
|
||||
api_key,
|
||||
api_url,
|
||||
timeout=1.5 if for_picker else 5.0, # picker: fail fast so a slow custom endpoint doesn't block /model
|
||||
headers=_extra_headers_from_config(ep_cfg) or None,
|
||||
)
|
||||
if live_models:
|
||||
@@ -2769,7 +2770,11 @@ def list_authenticated_providers(
|
||||
try:
|
||||
from hermes_cli.models import fetch_api_models
|
||||
|
||||
_live_models = fetch_api_models("", str(current_base_url).strip().rstrip("/"))
|
||||
_live_models = fetch_api_models(
|
||||
"",
|
||||
str(current_base_url).strip().rstrip("/"),
|
||||
timeout=1.5 if for_picker else 5.0, # picker: fail fast on a slow current endpoint
|
||||
)
|
||||
if _live_models:
|
||||
_models = _live_models
|
||||
except Exception:
|
||||
@@ -3012,6 +3017,7 @@ def list_authenticated_providers(
|
||||
live_models = fetch_api_models(
|
||||
api_key,
|
||||
api_url,
|
||||
timeout=1.5 if for_picker else 5.0, # picker: fail fast so a slow custom endpoint doesn't block /model
|
||||
headers=grp.get("extra_headers") or None,
|
||||
)
|
||||
if live_models:
|
||||
|
||||
Reference in New Issue
Block a user