Cindy reads supportsFastMode from a model's service_tiers in /v1/models (a priority entry), and its import link asks /v1/models with no magpie header. The models handler gave service_tiers (codexTiers, the tiers Codex here is offered on each model, #1234) only to a magpie asking with X-Magpie-Drawers, so Cindy never showed Fast on GPT-6-Astra / GPT-6.1-Sol. Every client now gets them; a model with no tier says nothing, and the remote-magpie path is unchanged. The context ring showing "—" in the same report is not touched: per the reporter's own reading it is Cindy's Codex runtime wanting native metadata, which /v1/models already carries as context_window. Run: - TestModelsListTiersForEveryClient (new): a relay's gpt-6.1-sol lists priority, its glm-5 lists none, on a plain GET /v1/models. Red on the old handler ("" for gpt-6.1-sol), green now. - go test -tags nogui ./internal/gateway on every test in the 39 files that GET /v1/models plus every *Tier* and *Fast* test: ok (110s). - gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows. - Not tried in a real Cindy: whether Cindy's Fast then sends service_tier priority through its Codex runtime is left to the reporter on the next release.
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package gateway
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// The model list every client reads names the tiers Codex here is offered
|
|
// on each model, not only the one another magpie asks for: Cindy shows its
|
|
// Fast switch on a model whose service_tiers hold priority, and its link
|
|
// asks /v1/models with no magpie header (tsuixl, #1914). A model offered
|
|
// no tier says nothing.
|
|
func TestModelsListTiersForEveryClient(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
if err := provider.Save(provider.Provider{ID: "relay", Name: "Relay", Key: "k", Models: []string{"gpt-6.1-sol", "glm-5"}, Responses: "http://relay.invalid/v1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
rec := httptest.NewRecorder()
|
|
New().Handler().ServeHTTP(rec, httptest.NewRequest("GET", "/v1/models", nil))
|
|
var list struct {
|
|
Data []struct {
|
|
ID string `json:"id"`
|
|
Tiers []struct {
|
|
ID string `json:"id"`
|
|
} `json:"service_tiers"`
|
|
} `json:"data"`
|
|
}
|
|
if err := json.Unmarshal(rec.Body.Bytes(), &list); err != nil {
|
|
t.Fatalf("%v: %s", err, rec.Body)
|
|
}
|
|
got := map[string]string{}
|
|
for _, m := range list.Data {
|
|
s := ""
|
|
for _, x := range m.Tiers {
|
|
s += x.ID + " "
|
|
}
|
|
got[m.ID] = s
|
|
}
|
|
for id, want := range map[string]string{"relay/gpt-6.1-sol": "priority ", "relay/glm-5": ""} {
|
|
if s, ok := got[id]; !ok || s != want {
|
|
t.Errorf("%s tiers %q (listed %v), want %q", id, s, ok, want)
|
|
}
|
|
}
|
|
}
|