diff --git a/pkg/config/config.go b/pkg/config/config.go index 97e78983c..ca598fdae 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -896,12 +896,12 @@ type BaiduSearchConfig struct { } type WebToolsConfig struct { - ToolConfig ` yaml:"-" envPrefix:"PICOCLAW_TOOLS_WEB_"` + ToolConfig ` yaml:"-" envPrefix:"PICOCLAW_TOOLS_WEB_"` Brave BraveConfig `yaml:"brave,omitempty" json:"brave"` Tavily TavilyConfig `yaml:"tavily,omitempty" json:"tavily"` Sogou SogouConfig `yaml:"-" json:"sogou"` DuckDuckGo DuckDuckGoConfig `yaml:"-" json:"duckduckgo"` - Gemini GeminiSearchConfig `yaml:"gemini,omitempty" json:"gemini"` + Gemini GeminiSearchConfig `yaml:"gemini,omitempty" json:"gemini"` Perplexity PerplexityConfig `yaml:"perplexity,omitempty" json:"perplexity"` SearXNG SearXNGConfig `yaml:"-" json:"searxng"` GLMSearch GLMSearchConfig `yaml:"glm_search,omitempty" json:"glm_search"` diff --git a/pkg/tools/integration/web.go b/pkg/tools/integration/web.go index 5693a106c..55a68a3a2 100644 --- a/pkg/tools/integration/web.go +++ b/pkg/tools/integration/web.go @@ -504,13 +504,16 @@ func (p *GeminiSearchProvider) Search( return "", fmt.Errorf("failed to marshal payload: %w", err) } - endpoint := fmt.Sprintf("https://generativelanguage.googleapis.com/v1beta/models/%s:generateContent", url.PathEscape(model)) + endpoint := fmt.Sprintf( + "https://generativelanguage.googleapis.com/v1beta/models/%s:generateContent", + url.PathEscape(model), + ) req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewBuffer(bodyBytes)) if err != nil { return "", fmt.Errorf("failed to create request: %w", err) } req.Header.Set("Content-Type", "application/json") - req.Header.Set("x-goog-api-key", p.apiKey) + req.Header.Set("X-Goog-Api-Key", p.apiKey) req.Header.Set("User-Agent", fmt.Sprintf(userAgentHonest, config.Version)) resp, err := p.client.Do(req) @@ -1338,12 +1341,6 @@ func (opts WebSearchToolOptions) resolveProviderName(query string) (string, erro } } - for _, name := range autoFallbackWebSearchProviders { - if opts.providerReady(name) { - return name, nil - } - } - return "", nil } diff --git a/pkg/tools/integration/web_test.go b/pkg/tools/integration/web_test.go index 2343e2c5e..7d2fc34c0 100644 --- a/pkg/tools/integration/web_test.go +++ b/pkg/tools/integration/web_test.go @@ -1909,8 +1909,8 @@ func TestGeminiSearchProvider_SearchSuccess(t *testing.T) { if req.Method != http.MethodPost { t.Fatalf("method = %s, want POST", req.Method) } - if got := req.Header.Get("x-goog-api-key"); got != "google-key" { - t.Fatalf("x-goog-api-key = %q, want google-key", got) + if got := req.Header.Get("X-Goog-Api-Key"); got != "google-key" { + t.Fatalf("X-Goog-Api-Key = %q, want google-key", got) } if !strings.Contains(req.URL.String(), "/models/gemini-2.5-flash:generateContent") { t.Fatalf("unexpected URL: %s", req.URL.String())