parent
e61786cc6b
commit
4bfa10f9e7
1 changed files with 17 additions and 17 deletions
|
|
@ -36,7 +36,8 @@ func (p *BraveSearchProvider) Search(ctx context.Context, query string, count in
|
|||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("X-Subscription-Token", p.apiKey)
|
||||
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
client := http.NewClient()
|
||||
client.Timeout = 10 * time.Second
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("request failed: %w", err)
|
||||
|
|
@ -96,7 +97,8 @@ func (p *DuckDuckGoSearchProvider) Search(ctx context.Context, query string, cou
|
|||
|
||||
req.Header.Set("User-Agent", userAgent)
|
||||
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
client := http.NewClient()
|
||||
client.Timeout = 10 * time.Second
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("request failed: %w", err)
|
||||
|
|
@ -206,7 +208,8 @@ func (p *PerplexitySearchProvider) Search(ctx context.Context, query string, cou
|
|||
req.Header.Set("Authorization", "Bearer "+p.apiKey)
|
||||
req.Header.Set("User-Agent", userAgent)
|
||||
|
||||
client := &http.Client{Timeout: 30 * time.Second}
|
||||
client := http.NewClient()
|
||||
client.Timeout = 30 * time.Second
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("request failed: %w", err)
|
||||
|
|
@ -410,20 +413,17 @@ func (t *WebFetchTool) Execute(ctx context.Context, args map[string]interface{})
|
|||
|
||||
req.Header.Set("User-Agent", userAgent)
|
||||
|
||||
client := &http.Client{
|
||||
Timeout: 60 * time.Second,
|
||||
Transport: &http.Transport{
|
||||
MaxIdleConns: 10,
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
DisableCompression: false,
|
||||
TLSHandshakeTimeout: 15 * time.Second,
|
||||
},
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
if len(via) >= 5 {
|
||||
return fmt.Errorf("stopped after 5 redirects")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
client := http.NewClient()
|
||||
client.Timeout = 60 * time.Second
|
||||
client.Transport.MaxIdleConns = 10
|
||||
client.Transport.IdleConnTimeout = 30 * time.Second
|
||||
client.Transport.DisableCompression = false
|
||||
client.Transport.TLSHandshakeTimeout = 15 * time.Second
|
||||
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||
if len(via) >= 5 {
|
||||
return fmt.Errorf("stopped after 5 redirects")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue