Settings › Search gets an Off choice beside Automatic and the providers. With it, no provider is asked to search for another model (no ChatGPT or Claude account's allowance spent, no Kimi Code search service, no Google sign-in's separate search), and the saved Search APIs are asked in their order; one failing never falls back to a provider. With Off and no ready Search API, magpie offers no search tool of its own. A provider's native search on the client's own protocol is unchanged. NorethSea's change (from their fork, feature/search-provider-off, 68fe54ff), cherry-picked onto main. On review one sibling was missing: ownSearcher and webSearchOf (what this magpie's model list tells another magpie about searching) still treated a Kimi Code plan or Google sign-in as searching for its models with Off. Both now go through searchesOwn, the one check canSearchFor uses, so with Off a remote magpie is told there is no search instead of adding a tool that has nothing behind it. Run: go test -tags nogui ./internal/gateway ./internal/gui ./internal/settings (sandbox HOME); TestSearchProviderOffTellsRemoteMagpie goes red with webSearchOf's old check put back; searcher-pick, gui-ja, gui-de, gui-zh-tw .test.cjs pass in Chromium and WebKit. Co-authored-by: NorethSea <963979204@qq.com>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package gateway
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// With provider search Off, this magpie's model list no longer tells
|
|
// another magpie that a Kimi Code plan's models are searched for by it:
|
|
// without a search API it adds no search tool to them (#1483).
|
|
func TestSearchProviderOffTellsRemoteMagpie(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
setHome(t, t.TempDir())
|
|
kimi := newKimiPlan(t)
|
|
p := provider.Provider{ID: "kimi", Name: "Kimi Code", Preset: "kimi-code-cn", Key: "sk-kimi",
|
|
Chat: kimi.URL + "/coding/v1", Models: []string{"kimi-for-coding"}}
|
|
if err := provider.Save(p); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
e := provider.Entry{Provider: p, Model: "kimi-for-coding"}
|
|
if got := webSearchOf(e, canSearch()); got != searchMagpie {
|
|
t.Fatalf("automatic: %q, want %q", got, searchMagpie)
|
|
}
|
|
st := settings.Load()
|
|
st.Searcher = "off"
|
|
if err := settings.Save(st); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := webSearchOf(e, canSearch()); got != "" {
|
|
t.Errorf("off, no search API: %q, want none", got)
|
|
}
|
|
}
|