workbuddy: two models of the same name are told apart (为啥会有两个 Deepseek-V4.1-Flash) — WorkBuddy AI's config gives deepseek-v4.1-flash (x0.00 credits) and deepseek-v4.1-flash-sg (Singapore, x0.03) both the name Deepseek-V4.1-Flash, and both are in its CLI agent's picker; a later model of a name already taken is now named for what its id adds to the first's, "Deepseek-V4.1-Flash (SG)", or else for its id. Both builds' lists go through it.

This commit is contained in:
yetone
2026-09-29 00:49:07 +08:00
parent 42aae751f5
commit 05094bed3d
2 changed files with 47 additions and 1 deletions
+23 -1
View File
@@ -13,6 +13,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"github.com/yetone/magpie/internal/catalog"
)
@@ -108,5 +109,26 @@ func (c wbProductConfig) cliModels() []catalog.Model {
out = append(out, m)
}
}
return out
return wbDistinctNames(out)
}
// wbDistinctNames tells apart models the config gives the same name:
// WorkBuddy AI lists deepseek-v4.1-flash (free) and deepseek-v4.1-flash-sg
// (Singapore, x0.03 credits) both as "Deepseek-V4.1-Flash". A later one is
// named for what its id adds to the first's ("… (SG)"), or else its id.
func wbDistinctNames(ms []catalog.Model) []catalog.Model {
first := map[string]string{} // name → the id that has it
for i, m := range ms {
id, ok := first[m.Name]
if !ok {
first[m.Name] = m.ID
continue
}
tag := m.ID
if rest, ok := strings.CutPrefix(m.ID, id+"-"); ok && rest != "" {
tag = strings.ToUpper(rest)
}
ms[i].Name = m.Name + " (" + tag + ")"
}
return ms
}
+24
View File
@@ -0,0 +1,24 @@
package provider
import (
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// Two models WorkBuddy names alike are told apart by what the second's id
// adds, or by its id.
func TestWorkBuddyDistinctNames(t *testing.T) {
ms := wbDistinctNames([]catalog.Model{
{ID: "deepseek-v4.1-flash", Name: "Deepseek-V4.1-Flash"},
{ID: "deepseek-v4.1-flash-sg", Name: "Deepseek-V4.1-Flash"},
{ID: "glm-5.3", Name: "GLM-5.3"},
{ID: "glm-x", Name: "GLM-5.3"},
})
want := []string{"Deepseek-V4.1-Flash", "Deepseek-V4.1-Flash (SG)", "GLM-5.3", "GLM-5.3 (glm-x)"}
for i, m := range ms {
if m.Name != want[i] {
t.Errorf("%s: %q, want %q", m.ID, m.Name, want[i])
}
}
}