qwen: /model names magpie's models as Names in agents' lists says (love1sbug on X)
The same report as the Claude Code fix before this one: Names in agents'
lists changed nothing in Qwen Code. magpie wrote each catalog model's
modelProviders.openai[].name as "magpie/<id>", and Qwen's /model shows
name as the row's label (the id beside it: @qwen-code/qwen-code's
dialog, `label: model.name`), so the setting had nothing to change.
qwenEntriesAt now writes the model's name as magpieModels gives it,
provider.Labels: "pro · DeepSeek" with the setting On, "pro" Off, a name
the user gave without its provider under Not on names I set. An entry
is found by its id, never by name, so the user's own entries ("[IdeaLab]
glm-5") and magpie's pick are unchanged.
TestQwenNamesFollowSuffixMode walks On, Not on names I set, Off and On
again through provider.SetSuffixMode with SyncCatalog and reads the
names back; it fails on the old qwen.go. TestQwen finds its entry by id.
Run: go test -tags nogui ./internal/agent ./internal/gui
./internal/provider; gofmt -l; go vet on darwin, GOOS=linux,
GOOS=windows.
Not tried: a real qwen in a sandbox HOME showing the new names.
This commit is contained in:
@@ -68,7 +68,11 @@ type qwenGen struct {
|
||||
func qwenEntriesAt(v1 string) []qwenEntry {
|
||||
var out []qwenEntry
|
||||
for _, m := range magpieModels("qwen") {
|
||||
e := qwenEntry{ID: m.ID, Name: magpieID + "/" + m.ID, BaseURL: v1, EnvKey: qwenEnvKey}
|
||||
// name is what /model shows, the id beside it when they differ:
|
||||
// the model's name as every agent's list calls it, by the Provider
|
||||
// in model names setting (magpie/<id> before, which none of the
|
||||
// setting's ways changed)
|
||||
e := qwenEntry{ID: m.ID, Name: m.Name, BaseURL: v1, EnvKey: qwenEnvKey}
|
||||
if m.Context > 0 {
|
||||
e.Generation = &qwenGen{ContextWindowSize: m.Context}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/gateway"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
@@ -130,7 +131,7 @@ func TestQwen(t *testing.T) {
|
||||
t.Errorf("%s missing: %v", id, order)
|
||||
continue
|
||||
}
|
||||
if e["name"] != "magpie/"+id || e["baseUrl"] != gatewayV1() || e["envKey"] != "MAGPIE_QWEN_API_KEY" {
|
||||
if e["name"] != listLabels("qwen")[id] || e["baseUrl"] != gatewayV1() || e["envKey"] != "MAGPIE_QWEN_API_KEY" {
|
||||
t.Errorf("%s: %v", id, e)
|
||||
}
|
||||
}
|
||||
@@ -153,9 +154,9 @@ func TestQwen(t *testing.T) {
|
||||
t.Fatalf("sync: %v", ms)
|
||||
}
|
||||
// something else rewrote magpie's entry: its baseUrl is the one
|
||||
// before its name, as the fields are ordered
|
||||
// before its id, as the fields are ordered
|
||||
cur := readFile(path)
|
||||
at := strings.Index(cur, `"magpie/anth/claude-sonnet-5"`)
|
||||
at := strings.Index(cur, `"id": "anth/claude-sonnet-5"`)
|
||||
base := strings.LastIndex(cur[:at], gatewayV1())
|
||||
if base < 0 {
|
||||
t.Fatal("no baseUrl before the entry's name:\n" + cur)
|
||||
@@ -345,3 +346,41 @@ func TestQwenHomeOverride(t *testing.T) {
|
||||
t.Fatalf("override: %s %s", a.Dir, a.Path)
|
||||
}
|
||||
}
|
||||
|
||||
// love1sbug on X: Names in agents' lists changed nothing in Qwen Code's
|
||||
// /model, which shows an entry's name (the id beside it), as magpie named
|
||||
// every entry magpie/<id>. The name follows the setting now, written again
|
||||
// as it changes.
|
||||
func TestQwenNamesFollowSuffixMode(t *testing.T) {
|
||||
_, path := qwenHome(t)
|
||||
writeFile(t, path, qwenUser)
|
||||
if err := provider.SetModelName("deepseek/flash", "Quick"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a, err := Find("qwen")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Apply("model", "magpie/deepseek/pro"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
catalog.Changed = SyncCatalog
|
||||
t.Cleanup(func() { catalog.Changed = nil })
|
||||
for _, c := range []struct{ mode, pro, flash string }{
|
||||
{provider.SuffixOn, "pro · DeepSeek", "Quick · DeepSeek"},
|
||||
{provider.SuffixOwn, "pro · DeepSeek", "Quick"},
|
||||
{provider.SuffixOff, "pro", "Quick"},
|
||||
{provider.SuffixOn, "pro · DeepSeek", "Quick · DeepSeek"},
|
||||
} {
|
||||
if err := provider.SetSuffixMode(c.mode); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ms, _, _ := qwenFile(t, path)
|
||||
if ms["deepseek/pro"]["name"] != c.pro || ms["deepseek/flash"]["name"] != c.flash {
|
||||
t.Fatalf("%s: %v / %v", c.mode, ms["deepseek/pro"], ms["deepseek/flash"])
|
||||
}
|
||||
if ms["glm-5"]["name"] != "[IdeaLab] glm-5" {
|
||||
t.Fatalf("%s: the user's entry renamed: %v", c.mode, ms["glm-5"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user