diff --git a/internal/gateway/search.go b/internal/gateway/search.go index 6cc15961b..993192387 100644 --- a/internal/gateway/search.go +++ b/internal/gateway/search.go @@ -565,7 +565,9 @@ type smallCand struct { // the vendor's own, not one of the shapes guessed at below: their model // stays in the pool though its ID carries a namespace colon (a relay's // cn:deepseek-v4.1-flash, #4359) or one of the words, and keep has said -// whether it sees. An ID that starts a group, a found group or, on a +// whether it sees. Only their "it sees" lifts the guess: a "takes no +// images" says nothing of whether the ID is a vendor's model, and keeps +// the guess as it was. An ID that starts a group, a found group or, on a // subscription, what magpie wrote into its agent, is magpie's own shape // whatever the user said of it, and stays out. func smallCands(p provider.Provider, keep func(catalog.Model) bool) []smallCand { @@ -575,11 +577,13 @@ func smallCands(p provider.Provider, keep func(catalog.Model) bool) []smallCand if keep != nil && !keep(m) { continue } - if _, said := provider.ImageOverrideIn(s, p.ID, m.ID); !said { + // a subscription's list can have what magpie wrote into its agent + if strings.HasPrefix(m.ID, provider.GroupPrefix) || strings.HasPrefix(m.ID, provider.AutoPrefix) || (p.Account != nil && strings.Contains(m.ID, "/")) { + continue + } + if sees, said := provider.ImageOverrideIn(s, p.ID, m.ID); !said || !sees { l := strings.ToLower(m.ID) - // a subscription's list can have what magpie wrote into its agent - if strings.HasPrefix(m.ID, provider.GroupPrefix) || strings.HasPrefix(m.ID, provider.AutoPrefix) || (p.Account != nil && strings.Contains(m.ID, "/")) || - strings.ContainsAny(l, ":~") || slices.ContainsFunc([]string{"nano", "lite", "image", "audio", "tts", "embed", "free"}, func(w string) bool { return strings.Contains(l, w) }) { + if strings.ContainsAny(l, ":~") || slices.ContainsFunc([]string{"nano", "lite", "image", "audio", "tts", "embed", "free"}, func(w string) bool { return strings.Contains(l, w) }) { continue } } diff --git a/internal/gateway/small_kept_test.go b/internal/gateway/small_kept_test.go index fdc7a957a..7b065ec10 100644 --- a/internal/gateway/small_kept_test.go +++ b/internal/gateway/small_kept_test.go @@ -224,6 +224,34 @@ func TestAutoVisionPicksANamespacedIDTheUserSaidSees(t *testing.T) { } } +// Only the user's "it sees" lifts the shape guess in the small models' +// pool (#4359): their "takes no images" says nothing of the ID, so a +// colon ID they marked so stays out of the searcher's pool too, and an ID +// of magpie's own shape (a group's, auto's) stays out whatever they said. +func TestSmallCandsLiftOnlyWhatTheUserSaidSees(t *testing.T) { + fresh(t) + p := provider.Provider{ID: "relay", Name: "Relay", Chat: "http://relay.invalid/v1", Key: "k", + Models: []string{provider.GroupPrefix + "g", provider.AutoPrefix + "a", "cn:text-only", "cn:sees", "cn:unsaid"}} + if err := provider.Save(p); err != nil { + t.Fatal(err) + } + st := settings.Load() + st.ModelImages = map[string]bool{ + "relay/" + provider.GroupPrefix + "g": true, "relay/" + provider.AutoPrefix + "a": true, + "relay/cn:text-only": false, "relay/cn:sees": true, + } + if err := settings.Save(st); err != nil { + t.Fatal(err) + } + var ids []string + for _, c := range smallCands(p, nil) { + ids = append(ids, c.id) + } + if len(ids) != 1 || ids[0] != "cn:sees" { + t.Fatalf("pool %v, want only cn:sees", ids) + } +} + // rankSmall's order is pickSmall's pick of every subset, as pickSmall // was before the ranking: the first of a subset is its pick. func TestRankSmallIsPickSmall(t *testing.T) {