Files
magpie/internal/usage/served_sep_test.go
T
yetone 4a87b30610 usage, gateway: a model the vendor spells with other separators isn't marked as another one (vincentzhang on Discord: 这个说明有点奇怪。看不明白。) — Volcengine Ark answers deepseek-v4.1-flash as deepseek-v4-1-flash, the dots written as hyphens, and the Usage page's Requests and the Routing page marked every such row amber 「实际 deepseek-v4-1-flash」, saying another model had answered, not the one asked for under a dated name. Swapped now compares the bare names without their separators (. - _ and spaces) and case, so deepseek-v4-1-flash, deepseek_v4_1_flash, GLM-4-6 for glm-4.6 and gpt-4-1-2025-04-14 for gpt-4.1 are the model asked for, while deepseek-v4-flash or deepseek-v4.1-pro for deepseek-v4.1-flash still are another. Rows and routes kept marked swapped before are read back as not swapped when the names differ only so (usage.SameSpelled, in rowChunk.row and Route.routedAgain). The tag's explanation says it in plainer words: asked for {sent}, the reply says {served} answered, likely another model; the same model under a dated name or spelled otherwise isn't marked (zh, ja, de). TestSwappedIgnoresSeparators fails on the old code; TestKeptRowSameSpelledNotSwapped, TestRouteKeptSpelledOtherwiseNotSwapped. usage-ledger (its expected title updated), remote-group-served, panel-routing, gui-ja and gui-de pass on WebKit. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass (TestCodexVersion timed out once under load and passes alone).
2026-10-05 12:49:59 +08:00

45 lines
1.6 KiB
Go

package usage
import "testing"
// A vendor that writes a version's dots as hyphens or underscores answered
// with the model asked for (vincentzhang on Discord: Volcengine Ark's
// deepseek-v4.1-flash answered as deepseek-v4-1-flash, marked another
// model); another model is still one.
func TestSwappedIgnoresSeparators(t *testing.T) {
for _, c := range [][2]string{
{"volcengine/deepseek-v4.1-flash", "deepseek-v4-1-flash"},
{"deepseek-v4.1-flash", "deepseek_v4_1_flash"},
{"glm-4.6", "GLM-4-6"},
{"gpt-4.1", "gpt-4-1-2025-04-14"},
{"doubao-seed-1.6", "doubao-seed-1-6-250615"},
} {
if Swapped(c[0], c[1]) {
t.Errorf("%s answered as %s is the same model", c[0], c[1])
}
}
for _, c := range [][2]string{
{"deepseek-v4.1-flash", "deepseek-v4-flash"},
{"deepseek-v4.1-flash", "deepseek-v4.1-pro"},
{"glm-4.6", "glm-4.5"},
{"claude-opus-5-5", "claude-sonnet-5-5"},
} {
if !Swapped(c[0], c[1]) {
t.Errorf("%s answered as %s is another model", c[0], c[1])
}
}
}
// A row kept marked swapped before is read back as not swapped when its
// model was only spelled otherwise; a real swap stays one.
func TestKeptRowSameSpelledNotSwapped(t *testing.T) {
c := &rowChunk{}
c.add(Row{Record: Record{Model: "deepseek-v4.1-flash", Served: "deepseek-v4-1-flash"}, Swapped: true}, "", 0, false)
c.add(Row{Record: Record{Model: "deepseek-v4.1-flash", Served: "deepseek-v4-flash"}, Swapped: true}, "", 1, false)
for _, chunk := range []*rowChunk{c, c.pack().unpack()} {
if chunk.row(0).Swapped || !chunk.row(1).Swapped {
t.Fatalf("same-spelled %v, other model %v", chunk.row(0).Swapped, chunk.row(1).Swapped)
}
}
}