cybershape asked for a client's model list to show only a group, not every model behind it. A provider could already be kept for routing groups (Provider.Unlisted), but that hides the whole provider, and the models a group names may come from providers used elsewhere too. Group.Unlists (json "unlists"): the models a group names (a member fixed at an effort counts as its model) and those its patterns match leave Catalog(), so `magpie models`, /v1/models and every agent's list (CatalogFor) show the group without them. They stay in Served(), so a group routes over them and a request naming one as provider/model is still answered, and Unlisted() returns them for the GUI as it does an unlisted provider's. A nested group keeps its own setting; a group switched off or hidden keeps nothing out. With no group unlisting, Catalog() takes a fast path and is unchanged. - Routing view: the group editor's "Model lists" (Its models too / The group alone, segmented, with a hint), saved with Save; the card shows "Its models unlisted". Both group Save paths send unlists. zh, zh-TW, ja, de. - CLI: `magpie group set <id> listed=no|yes`; `magpie group <id>` shows listed: no. - TUI: the group member picker offered Catalog(), so models kept out of the lists (an unlisted provider's, before this too) couldn't be put in a group from the TUI. It offers Served(), as the GUI's picker does. - docs/reference.md, Routing groups: listed=no. Product call: a per-group switch, off by default, rather than hiding members of every group, so existing lists don't change under anyone. Run: - go test ./internal/provider -run 'Group|Catalog|Unlisted|Served', ./internal/gui, root package, ./internal/tui: ok. TestGroupUnlistsItsModels fails with the Catalog filter removed; TestMemberOptionsOfferUnlistedModels fails with the picker on Catalog(); TestApplyGroupPairs covers listed=no/YES/maybe. - GUI group-unlists.test.cjs, Chromium and WebKit, en zh zh-TW ja de, at 1100px and 420px: 20/20. i18n-keys: ok. - gofmt; go vet darwin, windows, linux (-tags nogui): clean. Not tried: with the reporter's own client; a real agent's model file written after toggling (CatalogFor is covered by the test).
69 lines
2.5 KiB
Go
69 lines
2.5 KiB
Go
package tui
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// The member picker offers a group of decision models only decision
|
|
// models, a chat group none, and a new group both (ARNO on Discord).
|
|
func TestMemberOptionsDecisionGroup(t *testing.T) {
|
|
home(t)
|
|
if err := provider.Save(provider.Provider{ID: "ja", Name: "JA", Key: "k1", Decide: "http://127.0.0.1:1/v1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.Save(provider.Provider{ID: "jb", Name: "JB", Key: "k2", Decide: "http://127.0.0.1:1/v1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SaveGroup(provider.Group{ID: "jevs", Name: "Jevs", Members: []string{"ja/jev-latest"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SaveGroup(provider.Group{ID: "chat", Name: "Chat", Members: []string{"a/m"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
ids := func(skip []string, self string) []string {
|
|
var out []string
|
|
for _, o := range memberOptions(skip, self) {
|
|
out = append(out, o.Value)
|
|
}
|
|
return out
|
|
}
|
|
got := ids([]string{"ja/jev-latest"}, "jevs")
|
|
if !slices.Contains(got, "jb/jev-latest") || slices.Contains(got, "ja/jev-latest") || slices.ContainsFunc(got, func(id string) bool { return !provider.IsDecider(id) }) {
|
|
t.Fatalf("decision group offered %v", got)
|
|
}
|
|
if got := ids([]string{"a/m"}, "chat"); slices.Contains(got, "jb/jev-latest") || slices.Contains(got, "group/jevs") || len(got) == 0 {
|
|
t.Fatalf("chat group offered %v", got)
|
|
}
|
|
if got := ids(nil, ""); !slices.Contains(got, "jb/jev-latest") || !slices.Contains(got, "a/m") {
|
|
t.Fatalf("a new group offered %v", got)
|
|
}
|
|
}
|
|
|
|
// The member picker offers the models kept out of the lists agents see:
|
|
// a provider's kept for routing groups and a group's with listed=no
|
|
// (#1783), as the Routing view's does. They are what groups are made of.
|
|
func TestMemberOptionsOfferUnlistedModels(t *testing.T) {
|
|
home(t)
|
|
for _, p := range []provider.Provider{
|
|
{ID: "ua", Name: "UA", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m1"}},
|
|
{ID: "ub", Name: "UB", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"n1"}, Unlisted: true},
|
|
} {
|
|
if err := provider.Save(p); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if err := provider.SaveGroup(provider.Group{ID: "g", Name: "G", Members: []string{"ua/m1"}, Unlists: true}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var got []string
|
|
for _, o := range memberOptions(nil, "other") {
|
|
got = append(got, o.Value)
|
|
}
|
|
if !slices.Contains(got, "ua/m1") || !slices.Contains(got, "ub/n1") || !slices.Contains(got, "group/g") {
|
|
t.Fatalf("offered %v", got)
|
|
}
|
|
}
|