From 836d074f1a6299e7b13ce6ea0ba36c97839deb18 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 12 Nov 2026 22:59:14 +0800 Subject: [PATCH] providers: a model's maker logo is found for every catalog a preset names, StepFun's included (zzstar101 on X) IconForCatalog compared a models.dev id with the preset's whole Catalog string, so a preset naming several ("stepfun-ai-step-plan, stepfun-ai", "stepfun-step-plan, stepfun", Xiaomi MiMo's, Azure's) matched none of them and gave no logo for step-5-preview's catalog. It now also looks in each preset's list (Provider.Catalogs), after the presets whose catalog is exactly the id, so Azure's "azure, openai" never takes OpenAI's models. An empty id gives none (it matched a preset with no catalog). Run (mica, the load bar on mote): TestIconForCatalogFindsAListedCatalog red on the old presets.go (stepfun, stepfun-step-plan, azure, xiaomi-token-plan-cn), green on the new; go test of internal/provider, internal/agent and internal/gui ok; gofmt; go vet on darwin, linux nogui and windows. Not reproduced: the Models page names step-5-preview's maker by its id (agent.ModelIcon gives stepfun-color for every spelling tried), so this does not by itself explain the report's icon; it fixes the lookup the imported-provider path (importurl.go) and the by-catalog logos use. Not tried: the reporter's own provider list. --- internal/provider/icon_catalog_list_test.go | 18 ++++++++++++++++++ internal/provider/presets.go | 14 +++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 internal/provider/icon_catalog_list_test.go diff --git a/internal/provider/icon_catalog_list_test.go b/internal/provider/icon_catalog_list_test.go new file mode 100644 index 000000000..7014d66fd --- /dev/null +++ b/internal/provider/icon_catalog_list_test.go @@ -0,0 +1,18 @@ +package provider + +import "testing" + +// A preset names several catalogs; each one's models get its logo +// (zzstar101 on X: step-5-preview of "stepfun-ai" had none of StepFun's). +func TestIconForCatalogFindsAListedCatalog(t *testing.T) { + for id, want := range map[string]string{ + "stepfun-ai": "stepfun-color", "stepfun-ai-step-plan": "stepfun-color", + "stepfun": "stepfun-color", "stepfun-step-plan": "stepfun-color", + "xiaomi": "mimocode", "xiaomi-token-plan-cn": "mimocode", + "openai": "openai", "azure": "azure-color", "": "", + } { + if got := IconForCatalog(id); got != want { + t.Errorf("IconForCatalog(%q) = %q, want %q", id, got, want) + } + } +} diff --git a/internal/provider/presets.go b/internal/provider/presets.go index 86efc975e..c776fb959 100644 --- a/internal/provider/presets.go +++ b/internal/provider/presets.go @@ -972,12 +972,24 @@ func (p *Provider) atRegionOf(pr *PresetDef, r Region) { } // IconForCatalog names the logo of the vendor behind a models.dev -// provider id, or "" when no preset covers it. +// provider id, or "" when no preset covers it. A preset names several +// catalogs ("stepfun-ai-step-plan, stepfun-ai"), so an id is also found in +// that list; a preset whose catalog is exactly the id comes first, so +// Azure's "azure, openai" never gives OpenAI's models Azure's logo. func IconForCatalog(catalogID string) string { + if catalogID == "" { + return "" + } for _, p := range presets { if p.Catalog == catalogID || slices.ContainsFunc(p.Regions, func(r Region) bool { return r.Catalog == catalogID }) { return p.Icon } } + for _, p := range presets { + if slices.Contains(Provider{Catalog: p.Catalog}.Catalogs(), catalogID) || + slices.ContainsFunc(p.Regions, func(r Region) bool { return slices.Contains(Provider{Catalog: r.Catalog}.Catalogs(), catalogID) }) { + return p.Icon + } + } return "" }