fix(web/config): adapt glm and baidu key handling after security refactor

This commit is contained in:
Alix-007 2026-03-29 14:56:39 +08:00
parent 9db32d996b
commit 8fe293e8b1
2 changed files with 6 additions and 6 deletions

View file

@ -256,10 +256,10 @@ func applyWebSearchAPIKeyPatch(cfg *config.Config, patch webSearchAPIKeyPatch) {
cfg.Tools.Web.Perplexity.SetAPIKey(strings.TrimSpace(*patch.perplexityAPIKey))
}
if patch.glmSearchAPIKey != nil {
cfg.Tools.Web.GLMSearch.SetAPIKey(strings.TrimSpace(*patch.glmSearchAPIKey))
cfg.Tools.Web.GLMSearch.APIKey.Set(strings.TrimSpace(*patch.glmSearchAPIKey))
}
if patch.baiduSearchAPIKey != nil {
cfg.Tools.Web.BaiduSearch.SetAPIKey(strings.TrimSpace(*patch.baiduSearchAPIKey))
cfg.Tools.Web.BaiduSearch.APIKey.Set(strings.TrimSpace(*patch.baiduSearchAPIKey))
}
}

View file

@ -184,10 +184,10 @@ func assertWebSearchAPIKeys(t *testing.T, configPath string, want webSearchAPIKe
if got := cfg.Tools.Web.Perplexity.APIKey(); got != want.perplexity {
t.Fatalf("tools.web.perplexity.api_key = %q, want %q", got, want.perplexity)
}
if got := cfg.Tools.Web.GLMSearch.APIKey(); got != want.glm {
if got := cfg.Tools.Web.GLMSearch.APIKey.String(); got != want.glm {
t.Fatalf("tools.web.glm_search.api_key = %q, want %q", got, want.glm)
}
if got := cfg.Tools.Web.BaiduSearch.APIKey(); got != want.baidu {
if got := cfg.Tools.Web.BaiduSearch.APIKey.String(); got != want.baidu {
t.Fatalf("tools.web.baidu_search.api_key = %q, want %q", got, want.baidu)
}
}
@ -326,8 +326,8 @@ func seedWebSearchAPIKeys(t *testing.T, configPath string, keys webSearchAPIKeys
cfg.Tools.Web.Brave.SetAPIKey(keys.brave)
cfg.Tools.Web.Tavily.SetAPIKey(keys.tavily)
cfg.Tools.Web.Perplexity.SetAPIKey(keys.perplexity)
cfg.Tools.Web.GLMSearch.SetAPIKey(keys.glm)
cfg.Tools.Web.BaiduSearch.SetAPIKey(keys.baidu)
cfg.Tools.Web.GLMSearch.APIKey.Set(keys.glm)
cfg.Tools.Web.BaiduSearch.APIKey.Set(keys.baidu)
if err := config.SaveConfig(configPath, cfg); err != nil {
t.Fatalf("SaveConfig() error = %v", err)