diff --git a/internal/provider/group.go b/internal/provider/group.go index 3dbb6688e..150258cb7 100644 --- a/internal/provider/group.go +++ b/internal/provider/group.go @@ -828,9 +828,24 @@ func mergeKey(pid, model string, same map[string]string) string { if v := same[pid+"/"+model]; v != "" { return sameModel(v) } + if v := editionTwins[pid+"/"+model]; v != "" { + return sameModel(v) + } return sameModel(model) } +// editionTwins are the models a vendor's international edition lists +// under another id than its China edition does, which are the same model: +// the found groups merge each with its twin, as they merge Qoder's and +// Trae's two editions by their one id (Kts6M2fwWN43967 on X: WorkBuddy and +// WorkBuddy AI stayed two rows). The user's own "same as" (ModelSameAs) +// is read first. WorkBuddy AI lists deepseek-v4.1-flash under its paid +// id, -sg, which the product config names as the free id's paid id +// (allowPaidSwitch), so a signed-in account may list that one alone. +var editionTwins = map[string]string{ + "workbuddy-ai/deepseek-v4.1-flash-sg": "deepseek-v4.1-flash", +} + // AutoStandIn is the model a request for a group magpie found goes to while // such groups are off (SetAutoGroups), or once the providers the user keeps // out of them (SetAutoGroupSkip) took it away: its model, from the first diff --git a/internal/provider/group_test.go b/internal/provider/group_test.go index e8947fef4..a228027ec 100644 --- a/internal/provider/group_test.go +++ b/internal/provider/group_test.go @@ -138,3 +138,25 @@ func TestGroupSharesKimiFacts(t *testing.T) { t.Errorf("got %+v, want %+v", got, want) } } + +// WorkBuddy AI lists deepseek-v4.1-flash under its paid id, -sg, so the +// two editions' one model merged by id alone stayed two (Kts6M2fwWN43967 +// on X). The twin joins the group; another vendor's -sg id, and WorkBuddy +// AI's other models, are unchanged. +func TestAutoGroupsEditionTwins(t *testing.T) { + e := func(p, m string) Entry { + return Entry{ID: p + "/" + m, Model: m, Name: "DeepSeek-V4.1-Flash", Provider: Provider{ID: p}} + } + gs := autoGroups([]Entry{e("workbuddy", "deepseek-v4.1-flash"), e("workbuddy-ai", "deepseek-v4.1-flash-sg")}, nil) + if len(gs) != 1 || gs[0].ID != "auto-deepseek-v4-1-flash" || len(gs[0].Members) != 2 { + t.Fatalf("groups: %+v", gs) + } + if gs := autoGroups([]Entry{e("workbuddy", "deepseek-v4.1-flash"), e("other", "deepseek-v4.1-flash-sg")}, nil); len(gs) != 0 { + t.Errorf("another vendor's -sg model merged: %+v", gs) + } + // the user's own "same as" is read first + same := map[string]string{"workbuddy-ai/deepseek-v4.1-flash-sg": "deepseek-v4.1-flash-sg"} + if gs := autoGroups([]Entry{e("workbuddy", "deepseek-v4.1-flash"), e("workbuddy-ai", "deepseek-v4.1-flash-sg")}, same); len(gs) != 0 { + t.Errorf("the user's own same-as lost: %+v", gs) + } +}