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.
This commit is contained in:
happy5318
2026-05-09 10:31:06 +08:00
parent 0b7e1e60e8
commit a6599cd68e
+4 -3
View File
@@ -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