fix(web): satisfy gemini lint checks
This commit is contained in:
parent
7b861437c0
commit
b1caf97d72
3 changed files with 9 additions and 12 deletions
|
|
@ -896,12 +896,12 @@ type BaiduSearchConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebToolsConfig struct {
|
type WebToolsConfig struct {
|
||||||
ToolConfig ` yaml:"-" envPrefix:"PICOCLAW_TOOLS_WEB_"`
|
ToolConfig ` yaml:"-" envPrefix:"PICOCLAW_TOOLS_WEB_"`
|
||||||
Brave BraveConfig `yaml:"brave,omitempty" json:"brave"`
|
Brave BraveConfig `yaml:"brave,omitempty" json:"brave"`
|
||||||
Tavily TavilyConfig `yaml:"tavily,omitempty" json:"tavily"`
|
Tavily TavilyConfig `yaml:"tavily,omitempty" json:"tavily"`
|
||||||
Sogou SogouConfig `yaml:"-" json:"sogou"`
|
Sogou SogouConfig `yaml:"-" json:"sogou"`
|
||||||
DuckDuckGo DuckDuckGoConfig `yaml:"-" json:"duckduckgo"`
|
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"`
|
Perplexity PerplexityConfig `yaml:"perplexity,omitempty" json:"perplexity"`
|
||||||
SearXNG SearXNGConfig `yaml:"-" json:"searxng"`
|
SearXNG SearXNGConfig `yaml:"-" json:"searxng"`
|
||||||
GLMSearch GLMSearchConfig `yaml:"glm_search,omitempty" json:"glm_search"`
|
GLMSearch GLMSearchConfig `yaml:"glm_search,omitempty" json:"glm_search"`
|
||||||
|
|
|
||||||
|
|
@ -504,13 +504,16 @@ func (p *GeminiSearchProvider) Search(
|
||||||
return "", fmt.Errorf("failed to marshal payload: %w", err)
|
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))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewBuffer(bodyBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to create request: %w", err)
|
return "", fmt.Errorf("failed to create request: %w", err)
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
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))
|
req.Header.Set("User-Agent", fmt.Sprintf(userAgentHonest, config.Version))
|
||||||
|
|
||||||
resp, err := p.client.Do(req)
|
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
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1909,8 +1909,8 @@ func TestGeminiSearchProvider_SearchSuccess(t *testing.T) {
|
||||||
if req.Method != http.MethodPost {
|
if req.Method != http.MethodPost {
|
||||||
t.Fatalf("method = %s, want POST", req.Method)
|
t.Fatalf("method = %s, want POST", req.Method)
|
||||||
}
|
}
|
||||||
if got := req.Header.Get("x-goog-api-key"); got != "google-key" {
|
if got := req.Header.Get("X-Goog-Api-Key"); got != "google-key" {
|
||||||
t.Fatalf("x-goog-api-key = %q, want google-key", got)
|
t.Fatalf("X-Goog-Api-Key = %q, want google-key", got)
|
||||||
}
|
}
|
||||||
if !strings.Contains(req.URL.String(), "/models/gemini-2.5-flash:generateContent") {
|
if !strings.Contains(req.URL.String(), "/models/gemini-2.5-flash:generateContent") {
|
||||||
t.Fatalf("unexpected URL: %s", req.URL.String())
|
t.Fatalf("unexpected URL: %s", req.URL.String())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue