agent: a model Codex hides joins Codex's own group in the picker
v0.1.1737 offered a model the user ticked but Codex's bundled catalog
hides (GPT-6.1 Terra) under a "Codex" section of its own, beside the
provider's group. ysm119 asked on Discord why one provider's ticked
models showed up as two groups. codexViaMagpieFor now gives such a
model the group and icon of the provider's own entries and lists it
first among them.
Run: go test -run 'Codex|WSL|Wsl|Via|Magpie' ./internal/agent ok;
go vet ./internal/agent for darwin, windows and linux (nogui) ok;
gofmt clean.
Broken by hand: with the group assignment removed,
TestCodexHiddenTickedModelOffered fails ("gpt-h in \"Codex\", gpt-a in
\"OpenAI\"").
Not tried: the GUI picker with a real Codex account.
This commit is contained in:
+11
-6
@@ -2033,7 +2033,8 @@ func codexInMagpie(own []Option) []Option {
|
||||
// serves on a ChatGPT account that own, Codex's own list, leaves out: one
|
||||
// Codex hides from its picker (gpt-6.1-terra) but the user ticked on the
|
||||
// subscription was offered nowhere (ysm119 on Discord), as the hop is all
|
||||
// that reaches it.
|
||||
// that reaches it. Those come first, in own's group: a "Codex" section
|
||||
// of their own beside it read as a second kind of model (ysm119).
|
||||
func codexViaMagpieFor(own []Option) []Option {
|
||||
in := map[string]bool{}
|
||||
for _, o := range own {
|
||||
@@ -2042,14 +2043,18 @@ func codexViaMagpieFor(own []Option) []Option {
|
||||
in[m] = true
|
||||
}
|
||||
}
|
||||
var out []Option
|
||||
var hidden, out []Option
|
||||
for _, o := range viaMagpie("codex", "") {
|
||||
if strings.HasPrefix(o.Value, "codex/") && in[codexOwnOf(o.Value)] {
|
||||
continue
|
||||
if !strings.HasPrefix(o.Value, "codex/") {
|
||||
out = append(out, o)
|
||||
} else if !in[codexOwnOf(o.Value)] {
|
||||
if len(own) > 0 {
|
||||
o.Group, o.GroupIcon = own[0].Group, own[0].GroupIcon
|
||||
}
|
||||
hidden = append(hidden, o)
|
||||
}
|
||||
out = append(out, o)
|
||||
}
|
||||
return out
|
||||
return append(hidden, out...)
|
||||
}
|
||||
|
||||
// codexOwnViaMagpie is the catalog id magpie serves one of Codex's own
|
||||
|
||||
@@ -33,7 +33,21 @@ func TestCodexHiddenTickedModelOffered(t *testing.T) {
|
||||
}
|
||||
seen := map[string]int{}
|
||||
var all []string
|
||||
for _, o := range codex(home).Fields[0].Options(nil) {
|
||||
opts := codex(home).Fields[0].Options(nil)
|
||||
groups := map[string]string{}
|
||||
for _, o := range opts {
|
||||
m := o.Value
|
||||
if own := codexOwnOf(o.Value); own != "" {
|
||||
m = own
|
||||
}
|
||||
groups[m] = o.Group
|
||||
}
|
||||
// one section: the hidden one beside Codex's own, not under a heading
|
||||
// of its own (ysm119: "为啥会出现2 个分组")
|
||||
if groups["gpt-h"] != groups["gpt-a"] {
|
||||
t.Errorf("gpt-h in %q, gpt-a in %q", groups["gpt-h"], groups["gpt-a"])
|
||||
}
|
||||
for _, o := range opts {
|
||||
all = append(all, o.Group+":"+o.Value)
|
||||
m := o.Value
|
||||
if own := codexOwnOf(o.Value); own != "" {
|
||||
|
||||
Reference in New Issue
Block a user