From a6599cd68e2f2fc3fdc891c17c2cd2850d79819b Mon Sep 17 00:00:00 2001 From: happy5318 Date: Sat, 9 May 2026 10:31:06 +0800 Subject: [PATCH] fix: show same model from different custom providers instead of deduplicating When multiple custom providers expose the same model ID (e.g. baidu, huoshan, and liantong all offering glm-5.1), only the first provider's entry was shown in the model dropdown. Root cause (backend): used the bare model ID as the dedup key, so the second and subsequent providers with the same model were silently skipped. Root cause (frontend): stripped the @provider: prefix before comparing, so @custom:baidu:glm-5.1 and @custom:huoshan:glm-5.1 were treated as duplicates. Fix: - Backend: change _seen_custom_ids key to '{slug}:{model_id}' so each provider's models are tracked independently. - Frontend: add _providerOf() helper and deduplicate on the composite (normId, provider) key instead of normId alone. Bare model IDs (without @provider: prefix) still deduplicate on normId for backward compatibility. --- api/config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/config.py b/api/config.py index 27de96d2..f8ad2a42 100644 --- a/api/config.py +++ b/api/config.py @@ -2949,7 +2949,7 @@ def get_available_models() -> dict: _custom_providers_cfg = cfg.get("custom_providers", []) _named_custom_groups: dict = {} if isinstance(_custom_providers_cfg, list): - _seen_custom_ids = {m["id"] for m in auto_detected_models} + _seen_custom_ids = set() for _cp in _custom_providers_cfg: if not isinstance(_cp, dict): continue @@ -2970,9 +2970,10 @@ def get_available_models() -> dict: _cp_model_ids.append(_m_id.strip()) for _cp_model in _cp_model_ids: - if _cp_model and _cp_model not in _seen_custom_ids: + _dedup_key = f"{_slug}:{_cp_model}" if _slug else _cp_model + if _cp_model and _dedup_key not in _seen_custom_ids: _cp_label = _get_label_for_model(_cp_model, []) - _seen_custom_ids.add(_cp_model) + _seen_custom_ids.add(_dedup_key) if _slug: detected_providers.add(_slug) _cp_option_id = _cp_model