Files
magpie/internal/provider/host_efforts_test.go
T
yetone a85b2434ab models: reasoning levels are borrowed again for models Azure also hosts, and a routing group keeps its members' levels when one thinks with none to pick from (ARNO on Discord: routing group在接入harness的时候,没有设置reasoning_efforts。我发现是之前很多能自动推导reasoning_efforts列表的模型现在都推导失败了) — the Azure OpenAI preset (c35471cf, Catalog "azure, openai") was taken for a maker, so models.dev's azure list was the maker's word on every model it hosts: Kimi K2.5, DeepSeek V3.2 and R1, Grok 4.20/4.1 Fast Reasoning, listed there with no levels, took none on a relay or custom provider (and the gateway capped them at high as levelless), where the providers listing any give low…high, none/high and the rest. Azure is now marked Hosts, as Groq and Ollama Cloud are; its own provider still takes its own list's word. And groupEntries narrowed a group to the levels every member has, so one member that thinks with no levels (a thinking switch, a Claude 4.5 with a budget alone, OpenRouter's qwen3.8-omni-flash) left the group none and dsh's route wrote it without reasoningEfforts; such a member is now skipped as an unknown one is, since the gateway sends it the effort asked, no more than high (fitFor). The same Entry.Efforts feeds dsh, Codex's catalog, Pi and OpenCode. On a copy of the owner's config and models.dev cache: no plain model loses levels; group/auto-claude-haiku-4-5 and -sonnet-4-5 get low/medium/high/max again (they had them on 09-30), group/auto-qwen3-8-omni-flash none/low/medium/xhigh; across models.dev, the 34 ids Azure emptied (kimi-k2.5, deepseek-v3.2, deepseek-r1, grok-4-20-reasoning …) borrow again. TestHostListIsNoMakersWord (provider) and TestDshGroupHasItsMembersLevels (agent: the group's dsh entry has reasoningEfforts and the thinking field offers low/high/max) fail on the old code. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.
2026-10-03 18:17:11 +08:00

75 lines
2.8 KiB
Go

package provider
import (
"os"
"path/filepath"
"slices"
"strings"
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// ARNO on Discord: 我发现是之前很多能自动推导 reasoning_efforts 列表的模型
// 现在都推导失败了. The Azure OpenAI preset (Catalog "azure, openai") was
// taken for a maker, so models.dev's azure list — Kimi K2.5, DeepSeek V3.2
// and R1, Grok 4.20 Reasoning, served there with no levels listed — was the
// maker's word on them: a relay serving kimi-k2.5 or deepseek-v3.2 took no
// levels, though the providers listing any give them, and the agents
// offered no thinking for it. Azure hosts other makers' models, as Groq
// does; its own provider still takes its own list's word.
func TestHostListIsNoMakersWord(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
if err := os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(catalog.CachePath(), []byte(`{
"azure": {"models": {
"kimi-k2.5": {"id":"kimi-k2.5","reasoning":true},
"deepseek-v3.2": {"id":"deepseek-v3.2","reasoning":true}}},
"novita": {"models": {
"kimi-k2.5": {"id":"kimi-k2.5","reasoning":true,"reasoning_options":[{"type":"effort","values":["low","medium","high"]}]},
"deepseek-v3.2": {"id":"deepseek-v3.2","reasoning":true,"reasoning_options":[{"type":"effort","values":["none","high"]}]}}},
"deepinfra": {"models": {
"kimi-k2.5": {"id":"kimi-k2.5","reasoning":true,"reasoning_options":[{"type":"effort","values":["low","medium","high"]}]},
"deepseek-v3.2": {"id":"deepseek-v3.2","reasoning":true,"reasoning_options":[{"type":"effort","values":["none","high"]}]}}}
}`), 0o644); err != nil {
t.Fatal(err)
}
catalog.Reset()
t.Cleanup(catalog.Reset)
if slices.Contains(makerCatalogs(), "azure") {
t.Errorf("azure is taken for a maker: %v", makerCatalogs())
}
if err := Save(Provider{ID: "relay", Name: "Relay", Chat: "https://relay.test/v1", Key: "k", Models: []string{"kimi-k2.5", "deepseek-v3.2"}}); err != nil {
t.Fatal(err)
}
if err := catalog.SaveLive("relay", "https://relay.test/v1", []catalog.Model{{ID: "kimi-k2.5"}, {ID: "deepseek-v3.2"}}); err != nil {
t.Fatal(err)
}
got := map[string]string{}
for _, e := range Catalog() {
got[e.ID] = strings.Join(e.Efforts, ",")
}
for id, want := range map[string]string{
"relay/kimi-k2.5": "low,medium,high",
"relay/deepseek-v3.2": "none,high",
} {
if got[id] != want {
t.Errorf("%s: levels %q, want %q", id, got[id], want)
}
}
relay, err := Find("relay")
if err != nil {
t.Fatal(err)
}
if relay.Levelless("kimi-k2.5") {
t.Error("relay's kimi-k2.5 is said to have no levels")
}
}