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.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user