axelburks on Discord: a relay serves its decision model under a name of its own (an Ark endpoint id). A key's provider with a System One URL beside a conversation URL can set a model's API to decide (System One in Model settings' API row, its chip's right-click, or `magpie model api <pid/model> decide`). The model is then a decision model there: asked on System One by its own name, offered to routing groups, kept out of the conversation models, and a turn for it is refused with 400 before the vendor is asked. Auto gives it back. A provider with no System One URL, with that URL alone, an account, a remote magpie and Vertex refuse it, saying why. Chat routing (apisAmong) ignores decide. Broken by hand: removing the decideSet check in DecidesModel turns TestModelSetToSystemOneIsADecisionModel and TestModelSetToSystemOneAskedThere red. Run, on this stack over origin/main0fc3455e2(mote's suite lock had hours of queue, so the suites ran on WSL magpie-desktop under flock): - go test -timeout 45m ./internal/{provider,gateway,gui,cli,settings,fx} on WSL, ok; ./internal/codexcat on mote, ok; gofmt -l clean; go vet on mac, GOOS=linux -tags nogui and GOOS=windows on mote, ok; TestCoreScriptBudget ok (paid by cutting comments, no raise). - GUI, both engines, every language, on WSL at the pushed head and at0fc3455e2: every touched test file plus the provider-editor files a first run found red. No red at head that isn't red at0fc3455e2. The shared reds have issues: i18n-keys #5332, model-chip-steady #4388, model-copy-id #4621, models-works-only #4391, plugin-move-unserved #4392, provider-fetch-again #5232, provider-levels-save #4394, provider-levels-scroll #4395, provider-models-rest #4396, provider-picks-stay #4397, provider-typed #4673, remote-magpie #4398, zero-priced-free #5262, model-reasonless (webkit de) #4100, name-suffix-no-names #1937. - Rebased on origin/main4ab1191bc(gateway.go moved under it) and run again at the pushed head: gateway and provider ok on WSL, gofmt, vet (mac, linux nogui, windows) and the budget ok, i18n-keys, model-headers and routing-groups-back with only #5332's red. Not run at push: the whole GUI suite (1277 files). Not tried: a real relay's System One endpoint; fake vendors only. Reported-by: axelburks (Discord)
88 lines
3.1 KiB
Go
88 lines
3.1 KiB
Go
package provider
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// axelburks on Discord: a key's provider with a System One URL beside its
|
|
// chat URL serves a decision model under a name of its own (an Ark
|
|
// endpoint id); the model's API can be set to System One, which makes it a
|
|
// decision model there: offered to routing groups, asked on System One by
|
|
// its own name, and kept out of the conversation models. Auto again gives
|
|
// it back to them.
|
|
func TestModelSetToSystemOneIsADecisionModel(t *testing.T) {
|
|
prefillHome(t)
|
|
if err := Save(Provider{ID: "ark", Name: "Ark", Key: "ark-k", Chat: "https://ark.example/api/v3",
|
|
Decide: "https://ark.example/api/v3/systemone", Models: []string{"ep-chat", "ep-decide"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := SetModelAPI("ark/ep-decide", "decide"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
p, err := Find("ark")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !p.DecidesModel("ep-decide") || p.DecidesModel("ep-chat") {
|
|
t.Fatalf("decides: ep-decide %v, ep-chat %v", p.DecidesModel("ep-decide"), p.DecidesModel("ep-chat"))
|
|
}
|
|
if api, ok := p.ModelAPI("ep-decide"); !ok || api != DecideAPI {
|
|
t.Fatalf("ModelAPI = %q %v", api, ok)
|
|
}
|
|
if m, ok := resolveDecideModel(*p, "ep-decide"); !ok || m != "ep-decide" {
|
|
t.Fatalf("asked on System One as %q %v, want its own name", m, ok)
|
|
}
|
|
ids := func(es []Entry) []string {
|
|
var out []string
|
|
for _, e := range es {
|
|
if strings.HasPrefix(e.ID, "ark/") {
|
|
out = append(out, e.ID)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
if got := ids(Deciders()); !slices.Contains(got, "ark/ep-decide") || slices.Contains(got, "ark/ep-chat") {
|
|
t.Fatalf("Deciders = %v", got)
|
|
}
|
|
if got := ids(buildEntries()); !slices.Contains(got, "ark/ep-chat") || slices.Contains(got, "ark/ep-decide") {
|
|
t.Fatalf("conversation models = %v", got)
|
|
}
|
|
|
|
// Auto: a conversation model again
|
|
if err := SetModelAPI("ark/ep-decide", ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p, _ = Find("ark"); p.DecidesModel("ep-decide") {
|
|
t.Fatal("still a decision model after Auto")
|
|
}
|
|
if got := ids(buildEntries()); !slices.Contains(got, "ark/ep-decide") {
|
|
t.Fatalf("conversation models after Auto = %v", got)
|
|
}
|
|
}
|
|
|
|
// Only a key's provider with a System One URL beside a conversation URL
|
|
// takes it: one with no System One URL, or with that alone (every model a
|
|
// decision model already), refuses it, saying why.
|
|
func TestModelSystemOneNeedsItsURL(t *testing.T) {
|
|
prefillHome(t)
|
|
for _, p := range []Provider{
|
|
{ID: "relay", Name: "Relay", Key: "k", Chat: "https://relay.example/v1", Models: []string{"m"}},
|
|
{ID: "jev", Name: "Jev", Key: "k", Decide: "https://jev.example/v1", Models: []string{"m"}},
|
|
} {
|
|
if err := Save(p); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := SetModelAPI(p.ID+"/m", "decide"); err == nil || !strings.Contains(err.Error(), "System One") {
|
|
t.Fatalf("%s: %v", p.ID, err)
|
|
}
|
|
}
|
|
if (Provider{Decide: "https://x/v1", Chat: "https://x/v1", Account: &Account{}}).TakesDecideAPI() {
|
|
t.Fatal("an account takes it")
|
|
}
|
|
if (Provider{Decide: "https://x/v1", Chat: "https://x/v1", Preset: RemoteMagpiePreset}).TakesDecideAPI() {
|
|
t.Fatal("a remote magpie takes it")
|
|
}
|
|
}
|