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("Accept", "application/json")
|
||||||
req.Header.Set("X-Subscription-Token", p.apiKey)
|
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)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("request failed: %w", err)
|
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)
|
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)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("request failed: %w", err)
|
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("Authorization", "Bearer "+p.apiKey)
|
||||||
req.Header.Set("User-Agent", userAgent)
|
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)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("request failed: %w", err)
|
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)
|
req.Header.Set("User-Agent", userAgent)
|
||||||
|
|
||||||
client := &http.Client{
|
client := http.NewClient()
|
||||||
Timeout: 60 * time.Second,
|
client.Timeout = 60 * time.Second
|
||||||
Transport: &http.Transport{
|
client.Transport.MaxIdleConns = 10
|
||||||
MaxIdleConns: 10,
|
client.Transport.IdleConnTimeout = 30 * time.Second
|
||||||
IdleConnTimeout: 30 * time.Second,
|
client.Transport.DisableCompression = false
|
||||||
DisableCompression: false,
|
client.Transport.TLSHandshakeTimeout = 15 * time.Second
|
||||||
TLSHandshakeTimeout: 15 * time.Second,
|
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||||
},
|
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
|
||||||
if len(via) >= 5 {
|
if len(via) >= 5 {
|
||||||
return fmt.Errorf("stopped after 5 redirects")
|
return fmt.Errorf("stopped after 5 redirects")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue