timonwong (#3911, also on Discord #feedback): with a group of a/x and
b/x, unchecking x in provider a's model list struck a/x on the Routing
page, but group/<id> still sent requests to a. membersOff resolved each
member through resolveIn, whose provider/model step takes any model of
a provider that is on, so that a request can name a model its list
lacks.
membersOff now skips a member whose provider has picks and whose served
models lack it (unpicked), as timonwong's fork did (38615ca9). A
provider with no picks still routes a model its list lacks (#2642), a
decision model (never in the catalog) is still a decision group's, and
a request naming a/x itself still reaches a. Every route mode goes
through membersOff (ordered, weighted, rotate, manual, nested groups,
found groups, count_tokens' group lookup), so all of them get it. The
entries map is built only when a member's provider has picks.
The Routing card's memberInfo (gui/groups.go) used Resolve too, so a
manual group's pick row showed an unchecked member as ready; it now
asks provider.ResolveRoute, the same check, and the group is not ready
when its picked member was unchecked.
Tests: group_model_pick_test.go (ordered, weight, rotate; nested; a/x
named directly still served; checked again comes back; a decision
group keeps a picked decider) and gui's
TestGroupMemberUncheckedInItsProvider.
Run (mote, at this tree plus the next commit):
- Red on c30e2a645 with only the tests: the three route modes, the
nested case and the GUI test fail ("from ka"); direct and checked
again pass, as they should.
- Broken by hand: without len(p.Models) > 0, seven gateway tests go
red (TestNativeCompactionWriterThroughAGroupWhoseListLacksTheModel,
TestCodexSpentMovesToNextGroupMember, TestWeightedGroupGivesALowGroupItsShare,
TestVideoGroupMovesOnToTheNextMember, TestPolicyRefusalMovesToNextGroupMember,
TestCodexSealedAgentHandoffGoesToGroupsChatGPTAccount,
TestClaudeClientCacheGroupKeyKeepsMarks); without !DecidesModel,
TestDecisionGroupKeepsAPickedDecider goes red.
- go vet (darwin, GOOS=linux, GOOS=windows) on provider, gateway, gui:
clean; gofmt -l clean.
- go test -tags nogui -timeout 45m ./...: 76 packages ok; one red,
internal/plugin TestGatewayHookMixedPiPackage "starting plugins:
context deadline exceeded" at load ~134 (#2865, filed); it passes
alone on the same tree (26s).
Not tried: the real GUI app with a real provider; no GUI JS changed,
so the Playwright suite was not run.
Co-authored-by: timonwong <timon86.wang@gmail.com>
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package gui
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A group's member the user unchecked in its provider's model list is
|
|
// not ready on the Routing page (#3911), as the gateway skips it: a
|
|
// manual group's card struck nothing while the editor struck it.
|
|
func TestGroupMemberUncheckedInItsProvider(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
if err := provider.Save(provider.Provider{ID: "a", Name: "A", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"x", "y"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.Save(provider.Provider{ID: "b", Name: "B", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"x"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SaveGroup(provider.Group{ID: "mine", Name: "Mine", Members: []string{"a/x", "b/x"}, Routing: provider.Manual, Pick: "a/x"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
ready := func() map[string]bool {
|
|
out := map[string]bool{}
|
|
for _, g := range groupsState().Groups {
|
|
if g.ID == "mine" {
|
|
out["group"] = g.Ready
|
|
for _, m := range g.Info {
|
|
out[m.ID] = m.Ready
|
|
}
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
if r := ready(); !r["a/x"] || !r["b/x"] || !r["group"] {
|
|
t.Fatalf("before: %v", r)
|
|
}
|
|
if err := provider.SetModels("a", []string{"y"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if r := ready(); r["a/x"] || !r["b/x"] || r["group"] {
|
|
t.Fatalf("a/x unchecked: %v", r)
|
|
}
|
|
if _, _, ok := provider.Resolve("a/x"); !ok {
|
|
t.Fatal("a/x named directly no longer resolves")
|
|
}
|
|
}
|