fix(web): satisfy gemini lint checks

This commit is contained in:
Anton Bogdanovich 2026-05-11 09:32:39 -07:00
parent 7b861437c0
commit b1caf97d72
3 changed files with 9 additions and 12 deletions

View file

@ -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"`

View file

@ -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
}

View file

@ -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())