nb5p on Discord: (1) a custom provider set to Responses had its models
wired into dsh on magpie's Chat Completions route (`magpie`), so dsh sent
Chat and magpie translated; (2) in dsh's models, mygateway/gpt-6.1-sol was
"GPT-6.1 Sol" while mygateway/gpt-6.1-terra was "GPT-6.1 Terra · MyGateway".
Cause 1: Provider.Native never read BaseAPI, the API the user gave the
Base URL as. Detect fills in every API that answers, so a relay picked as
Responses also had a Chat URL, and Native returned Chat (out[0]). Native
now takes BaseAPI after the vendor rules (ResponsesFirst, MessagesFirst),
when the provider serves it. dsh supports it: dsh 0.2.1-rc.2 bundles
@earendil-works/pi-ai, whose KnownApi includes "openai-responses", and
magpie already has the `magpie-responses` route (dshKinds). Siblings
reading m.APIs from magpieModels move with it: dsh, Pi, omp, droid,
Grok Build.
Cause 2: provider.Labels counted collisions over models and routing
groups together. A model two providers serve gets an auto group with the
model's name, so the shown model collided with its own group and kept
"· Provider" (terra: served by a second provider too, hidden for dsh;
sol: one provider). Models and groups are counted apart now: a model
keeps its suffix only when another model reads the same, and a group
named like anything else keeps "· routing group". Labels feeds every
agent's list, so this holds for all of them.
Not changed: the gateway's usable() still orders a translated request
Chat first and doesn't read BaseAPI (#4508).
Tests (each red on the old code, broken by hand in a worktree on
origin/main: all new cases red; reverting only Native red on the route,
reverting only Labels red on terra's name; the old dsh output reproduced
the report exactly):
- internal/agent TestDshCustomResponsesProvider (new): both models on
magpie-responses, none on magpie, named "GPT-6.1 Sol"/"GPT-6.1 Terra".
- internal/provider native_test: Responses picked beside Chat, Chat
picked, Responses picked for a Claude where Messages is served, and
Responses picked with no Responses URL.
- plainnames/plainown_groups/suffix_mode expectations updated to the rule.
Run on mote, at this change on 7fe191cec (the pushed head is the same
change rebased on a newer origin/main, 6f435677c; not re-run there):
go test -tags nogui -count=1 -timeout 45m ./internal/provider
./internal/agent ./internal/gateway ./internal/cli ./internal/gui:
provider ok 170s, agent ok 303s, gateway ok 797s, cli ok 53s; gui FAIL
TestColdTurnsTaken only (0.00s, a test race untouched by this change,
filed #4510). gofmt -l clean. Still running at push: TestColdTurnsTaken
-count=20 and GOOS=linux/windows go vet ./... on mote, and the test on
origin/main alone.
Not tried: a real dsh session against a real Responses relay; nb5p's
own providers.json (the second provider serving terra is inferred from
the suffix); the GUI suite (no GUI file changed); the full ./... suite.
68 lines
2.4 KiB
Go
68 lines
2.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// nb5p on Discord: a custom provider set to the Responses API, whose Chat
|
|
// URL was found beside it, had its models written to dsh's Chat route, so
|
|
// dsh asked them on Chat Completions. And with Provider in model names
|
|
// off, its GPT-6.1 Terra, which another provider serves too, was named
|
|
// "GPT-6.1 Terra · MyGateway" beside the group found for it while its
|
|
// GPT-6.1 Sol had no suffix. The models go on magpie-responses (dsh's
|
|
// pi-ai takes "openai-responses" for a route), both named alone.
|
|
func TestDshCustomResponsesProvider(t *testing.T) {
|
|
home, dir, web := dshRouteHome(t)
|
|
dshKeyFixture(dir)
|
|
base := "http://127.0.0.1:1/v1"
|
|
for _, p := range []provider.Provider{
|
|
{ID: "mygateway", Name: "MyGateway", Key: "k", Chat: base, Responses: base, BaseAPI: "responses", Models: []string{"gpt-6.1-sol", "gpt-6.1-terra"}},
|
|
{ID: "other", Name: "Other", Key: "k", Chat: "http://127.0.0.1:2/v1", Models: []string{"gpt-6.1-terra"}},
|
|
} {
|
|
if err := provider.Save(p); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if err := catalog.SaveLive("mygateway", base, []catalog.Model{{ID: "gpt-6.1-sol", Name: "GPT-6.1 Sol"}, {ID: "gpt-6.1-terra", Name: "GPT-6.1 Terra"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := catalog.SaveLive("other", "http://127.0.0.1:2/v1", []catalog.Model{{ID: "gpt-6.1-terra", Name: "GPT-6.1 Terra"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SetHiddenModels("dsh", []string{"other/gpt-6.1-terra"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SetPlainNames(true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
os.WriteFile(web, []byte("# Your patch layer for this dsh profile.\n"), 0o644)
|
|
a := dsh(home)
|
|
if err := a.Field("model").Set("magpie/mygateway/gpt-6.1-sol"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
ps := dshPiProviders(t, web)
|
|
b, _ := os.ReadFile(web)
|
|
names := map[string]string{}
|
|
for _, m := range ps["magpie-responses"].Models {
|
|
names[m.ID] = m.Name
|
|
}
|
|
for id, want := range map[string]string{"mygateway/gpt-6.1-sol": "GPT-6.1 Sol", "mygateway/gpt-6.1-terra": "GPT-6.1 Terra"} {
|
|
got, ok := names[id]
|
|
if !ok {
|
|
t.Errorf("%s isn't on magpie-responses", id)
|
|
} else if got != want {
|
|
t.Errorf("%s named %q, want %q", id, got, want)
|
|
}
|
|
if contains(dshRouteModelIDs(ps["magpie"]), id) {
|
|
t.Errorf("%s is on the Chat route", id)
|
|
}
|
|
}
|
|
if t.Failed() {
|
|
t.Logf("%s", b)
|
|
}
|
|
}
|