feat: add bing search provider
Signed-off-by: joeyczheng <joeyczheng@tencent.com>
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
package web_search
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
)
|
||||
|
||||
const (
|
||||
// defaultBingSearchURL is the default Bing search API URL.
|
||||
// Reference: https://learn.microsoft.com/en-us/previous-versions/bing/search-apis/bing-web-search/reference/endpoints
|
||||
defaultBingSearchURL = "https://api.bing.microsoft.com/v7.0/search"
|
||||
)
|
||||
|
||||
var (
|
||||
// defaultUserAgentHeader for PC. https://learn.microsoft.com/en-us/previous-versions/bing/search-apis/bing-web-search/reference/headers
|
||||
defaultUserAgentHeader = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
|
||||
defaultBingTimeout = 10 * time.Second
|
||||
)
|
||||
|
||||
type bingSafeSearch string
|
||||
|
||||
const (
|
||||
bingSafeSearchOff bingSafeSearch = "Off"
|
||||
bingSafeSearchModerate bingSafeSearch = "Moderate"
|
||||
bingSafeSearchStrict bingSafeSearch = "Strict"
|
||||
)
|
||||
|
||||
type bingFreshness string
|
||||
|
||||
const (
|
||||
bingFreshnessDay = "Day"
|
||||
bingFreshnessWeek = "Week"
|
||||
bingFreshnessMonth = "Month"
|
||||
)
|
||||
|
||||
// BingProvider implements web search using Bing Search API
|
||||
type BingProvider struct {
|
||||
client *http.Client
|
||||
baseURL string
|
||||
apiKey string
|
||||
}
|
||||
|
||||
// NewBingProvider creates a new Bing provider
|
||||
func NewBingProvider() (interfaces.WebSearchProvider, error) {
|
||||
apiKey := os.Getenv("BING_SEARCH_API_KEY")
|
||||
if len(apiKey) == 0 {
|
||||
return nil, fmt.Errorf("BING_SEARCH_API_KEY is not set")
|
||||
}
|
||||
client := &http.Client{
|
||||
Timeout: defaultBingTimeout,
|
||||
}
|
||||
return &BingProvider{
|
||||
client: client,
|
||||
baseURL: defaultBingSearchURL,
|
||||
apiKey: apiKey,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// BingProviderInfo returns the provider info for registration
|
||||
func BingProviderInfo() types.WebSearchProviderInfo {
|
||||
return types.WebSearchProviderInfo{
|
||||
ID: "bing",
|
||||
Name: "Bing",
|
||||
Free: false,
|
||||
RequiresAPIKey: true,
|
||||
Description: "Bing Search API",
|
||||
}
|
||||
}
|
||||
|
||||
// Name returns the provider name
|
||||
func (p *BingProvider) Name() string {
|
||||
return "bing"
|
||||
}
|
||||
|
||||
// Search performs a web search using Bing Search API
|
||||
func (p *BingProvider) Search(
|
||||
ctx context.Context,
|
||||
query string,
|
||||
maxResults int,
|
||||
includeDate bool,
|
||||
) ([]*types.WebSearchResult, error) {
|
||||
if len(query) == 0 {
|
||||
return nil, fmt.Errorf("query is empty")
|
||||
}
|
||||
req, err := p.buildParams(ctx, query, maxResults, includeDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return p.doSearch(ctx, req)
|
||||
}
|
||||
|
||||
func (p *BingProvider) doSearch(ctx context.Context, req *http.Request) ([]*types.WebSearchResult, error) {
|
||||
resp, err := p.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var respData bingSearchResponse
|
||||
if err := json.Unmarshal(body, &respData); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal response: %w", err)
|
||||
}
|
||||
results := make([]*types.WebSearchResult, 0, len(respData.WebPages.Value))
|
||||
for _, item := range respData.WebPages.Value {
|
||||
results = append(results, &types.WebSearchResult{
|
||||
Title: item.Name,
|
||||
URL: item.URL,
|
||||
Snippet: item.Snippet,
|
||||
Source: "bing",
|
||||
PublishedAt: &item.DateLastCrawled,
|
||||
})
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// bingSearchResponse defines the response structure for Bing search API.
|
||||
// ref: https://learn.microsoft.com/en-us/previous-versions/bing/search-apis/bing-web-search/quickstarts/rest/go
|
||||
type bingSearchResponse struct {
|
||||
Type string `json:"_type"`
|
||||
QueryContext struct {
|
||||
OriginalQuery string `json:"originalQuery"`
|
||||
} `json:"queryContext"`
|
||||
WebPages struct {
|
||||
WebSearchURL string `json:"webSearchUrl"`
|
||||
TotalEstimatedMatches int `json:"totalEstimatedMatches"`
|
||||
Value []struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
IsFamilyFriendly bool `json:"isFamilyFriendly"`
|
||||
DisplayURL string `json:"displayUrl"`
|
||||
Snippet string `json:"snippet"`
|
||||
DateLastCrawled time.Time `json:"dateLastCrawled"`
|
||||
SearchTags []struct {
|
||||
Name string `json:"name"`
|
||||
Content string `json:"content"`
|
||||
} `json:"searchTags,omitempty"`
|
||||
About []struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"about,omitempty"`
|
||||
} `json:"value"`
|
||||
} `json:"webPages"`
|
||||
RelatedSearches struct {
|
||||
ID string `json:"id"`
|
||||
Value []struct {
|
||||
Text string `json:"text"`
|
||||
DisplayText string `json:"displayText"`
|
||||
WebSearchURL string `json:"webSearchUrl"`
|
||||
} `json:"value"`
|
||||
} `json:"relatedSearches"`
|
||||
RankingResponse struct {
|
||||
Mainline struct {
|
||||
Items []struct {
|
||||
AnswerType string `json:"answerType"`
|
||||
ResultIndex int `json:"resultIndex"`
|
||||
Value struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"value"`
|
||||
} `json:"items"`
|
||||
} `json:"mainline"`
|
||||
Sidebar struct {
|
||||
Items []struct {
|
||||
AnswerType string `json:"answerType"`
|
||||
Value struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"value"`
|
||||
} `json:"items"`
|
||||
} `json:"sidebar"`
|
||||
} `json:"rankingResponse"`
|
||||
}
|
||||
|
||||
// buildParams builds the request parameters for Bing search API.
|
||||
// ref: https://learn.microsoft.com/en-us/previous-versions/bing/search-apis/bing-web-search/quickstarts/rest/go
|
||||
func (p *BingProvider) buildParams(ctx context.Context, query string, maxResults int, includeDate bool) (*http.Request, error) {
|
||||
params := url.Values{}
|
||||
params.Set("q", query)
|
||||
params.Set("count", strconv.Itoa(maxResults))
|
||||
|
||||
queryURL := fmt.Sprintf("%s?%s", p.baseURL, params.Encode())
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", queryURL, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
req.Header.Set("User-Agent", defaultUserAgentHeader)
|
||||
req.Header.Set("Ocp-Apim-Subscription-Key", p.apiKey)
|
||||
return req, nil
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package web_search
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func setBingEnv(apiKey string) {
|
||||
os.Setenv("BING_SEARCH_API_KEY", apiKey)
|
||||
}
|
||||
|
||||
func unsetBingEnv() {
|
||||
os.Unsetenv("BING_SEARCH_API_KEY")
|
||||
}
|
||||
|
||||
func TestNewBingProvider(t *testing.T) {
|
||||
setBingEnv("test-api-key")
|
||||
defer unsetBingEnv()
|
||||
|
||||
provider, err := NewBingProvider()
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, provider)
|
||||
}
|
||||
|
||||
func TestBingProvider_Search(t *testing.T) {
|
||||
mockResponse := map[string]interface{}{
|
||||
"_type": "SearchResponse",
|
||||
"webPages": map[string]interface{}{
|
||||
"webSearchUrl": "https://www.bing.com/search?q=test",
|
||||
"totalEstimatedMatches": 1000,
|
||||
"value": []map[string]interface{}{
|
||||
{
|
||||
"id": "result-1",
|
||||
"name": "Test Result 1",
|
||||
"url": "https://example.com/1",
|
||||
"isFamilyFriendly": true,
|
||||
"displayUrl": "example.com/1",
|
||||
"snippet": "This is a test snippet 1",
|
||||
"dateLastCrawled": time.Now().Format(time.RFC3339),
|
||||
},
|
||||
{
|
||||
"id": "result-2",
|
||||
"name": "Test Result 2",
|
||||
"url": "https://example.com/2",
|
||||
"isFamilyFriendly": true,
|
||||
"displayUrl": "example.com/2",
|
||||
"snippet": "This is a test snippet 2",
|
||||
"dateLastCrawled": time.Now().Format(time.RFC3339),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "GET" {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
if r.Header.Get("Ocp-Apim-Subscription-Key") != "test-api-key" {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
query := r.URL.Query().Get("q")
|
||||
if query == "" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(mockResponse)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
provider := &BingProvider{
|
||||
client: server.Client(),
|
||||
baseURL: server.URL,
|
||||
apiKey: "test-api-key",
|
||||
}
|
||||
|
||||
t.Run("Successful search", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
results, err := provider.Search(ctx, "test query", 10, true)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, results, 2)
|
||||
assert.Equal(t, "Test Result 1", results[0].Title)
|
||||
assert.Equal(t, "https://example.com/1", results[0].URL)
|
||||
assert.Equal(t, "bing", results[0].Source)
|
||||
})
|
||||
|
||||
t.Run("Empty query", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
results, err := provider.Search(ctx, "", 10, true)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, results)
|
||||
assert.Contains(t, err.Error(), "query is empty")
|
||||
})
|
||||
}
|
||||
|
||||
func TestBingProvider_Search_Error(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
provider := &BingProvider{
|
||||
client: server.Client(),
|
||||
baseURL: server.URL,
|
||||
apiKey: "test-api-key",
|
||||
}
|
||||
|
||||
t.Run("Server error", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
results, err := provider.Search(ctx, "test query", 10, true)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, results)
|
||||
})
|
||||
}
|
||||
|
||||
func TestBingProvider_Search_InvalidJSON(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte("invalid json"))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
provider := &BingProvider{
|
||||
client: server.Client(),
|
||||
baseURL: server.URL,
|
||||
apiKey: "test-api-key",
|
||||
}
|
||||
|
||||
t.Run("Invalid JSON response", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
results, err := provider.Search(ctx, "test query", 10, true)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, results)
|
||||
assert.Contains(t, err.Error(), "failed to unmarshal response")
|
||||
})
|
||||
}
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/config"
|
||||
)
|
||||
|
||||
// testRoundTripper rewrites outgoing requests that target DuckDuckGo hosts
|
||||
@@ -46,7 +44,7 @@ func newTestClient(ts *httptest.Server) *http.Client {
|
||||
}
|
||||
|
||||
func TestDuckDuckGoProvider_Name(t *testing.T) {
|
||||
p, _ := NewDuckDuckGoProvider(config.WebSearchProviderConfig{})
|
||||
p, _ := NewDuckDuckGoProvider()
|
||||
if p.Name() != "duckduckgo" {
|
||||
t.Fatalf("expected provider name duckduckgo, got %s", p.Name())
|
||||
}
|
||||
@@ -80,7 +78,7 @@ func TestDuckDuckGoProvider(t *testing.T) {
|
||||
defer ts.Close()
|
||||
|
||||
// Build provider and inject our test client
|
||||
prov, _ := NewDuckDuckGoProvider(config.WebSearchProviderConfig{})
|
||||
prov, _ := NewDuckDuckGoProvider()
|
||||
dp := prov.(*DuckDuckGoProvider)
|
||||
if dp == nil {
|
||||
t.Fatalf("failed to build provider")
|
||||
@@ -141,7 +139,7 @@ func TestDuckDuckGoProvider_Fallback(t *testing.T) {
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
prov, _ := NewDuckDuckGoProvider(config.WebSearchProviderConfig{})
|
||||
prov, _ := NewDuckDuckGoProvider()
|
||||
dp := prov.(*DuckDuckGoProvider)
|
||||
if dp == nil {
|
||||
t.Fatalf("failed to build provider")
|
||||
@@ -171,7 +169,7 @@ func TestDuckDuckGoProvider_Search_Real(t *testing.T) {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
provider, err := NewDuckDuckGoProvider(config.WebSearchProviderConfig{})
|
||||
provider, err := NewDuckDuckGoProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create DuckDuckGo provider: %v", err)
|
||||
}
|
||||
@@ -239,7 +237,7 @@ func TestDuckDuckGo_SearchChinese(t *testing.T) {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
provider, err := NewDuckDuckGoProvider(config.WebSearchProviderConfig{})
|
||||
provider, err := NewDuckDuckGoProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create DuckDuckGo provider: %v", err)
|
||||
}
|
||||
|
||||
@@ -6,43 +6,47 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/config"
|
||||
)
|
||||
|
||||
func setGoogleEnv(apiURL string) {
|
||||
os.Setenv("GOOGLE_SEARCH_API_URL", apiURL)
|
||||
}
|
||||
|
||||
func unsetGoogleEnv() {
|
||||
os.Unsetenv("GOOGLE_SEARCH_API_URL")
|
||||
}
|
||||
|
||||
func TestNewGoogleProvider(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
cfg config.WebSearchProviderConfig
|
||||
apiURL string
|
||||
expected error
|
||||
}{
|
||||
{
|
||||
name: "valid config",
|
||||
cfg: config.WebSearchProviderConfig{
|
||||
APIURL: "https://customsearch.googleapis.com/customsearch/v1?api_key=test&engine_id=test",
|
||||
},
|
||||
name: "valid config",
|
||||
apiURL: "https://customsearch.googleapis.com/customsearch/v1?api_key=test&engine_id=test",
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
name: "missing engine id",
|
||||
cfg: config.WebSearchProviderConfig{
|
||||
APIURL: "https://customsearch.googleapis.com/customsearch/v1?api_key=test",
|
||||
},
|
||||
name: "missing engine id",
|
||||
apiURL: "https://customsearch.googleapis.com/customsearch/v1?api_key=test",
|
||||
expected: fmt.Errorf("engine_id is empty"),
|
||||
},
|
||||
{
|
||||
name: "missing api key",
|
||||
cfg: config.WebSearchProviderConfig{
|
||||
APIURL: "https://customsearch.googleapis.com/customsearch/v1?engine_id=test",
|
||||
},
|
||||
name: "missing api key",
|
||||
apiURL: "https://customsearch.googleapis.com/customsearch/v1?engine_id=test",
|
||||
expected: fmt.Errorf("api_key is empty"),
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
_, err := NewGoogleProvider(tc.cfg)
|
||||
setGoogleEnv(tc.apiURL)
|
||||
defer unsetGoogleEnv()
|
||||
_, err := NewGoogleProvider()
|
||||
|
||||
if tc.expected == nil {
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
@@ -60,10 +64,9 @@ func TestNewGoogleProvider(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGoogleProvider_Name(t *testing.T) {
|
||||
cfg := config.WebSearchProviderConfig{
|
||||
APIURL: "https://customsearch.googleapis.com/customsearch/v1?api_key=test&engine_id=test",
|
||||
}
|
||||
p, err := NewGoogleProvider(cfg)
|
||||
setGoogleEnv("https://customsearch.googleapis.com/customsearch/v1?api_key=test&engine_id=test")
|
||||
defer unsetGoogleEnv()
|
||||
p, err := NewGoogleProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create Google provider: %v", err)
|
||||
}
|
||||
@@ -115,10 +118,9 @@ func TestGoogleProvider_Search(t *testing.T) {
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
cfg := config.WebSearchProviderConfig{
|
||||
APIURL: fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL),
|
||||
}
|
||||
prov, err := NewGoogleProvider(cfg)
|
||||
setGoogleEnv(fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL))
|
||||
defer unsetGoogleEnv()
|
||||
prov, err := NewGoogleProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create Google provider: %v", err)
|
||||
}
|
||||
@@ -154,10 +156,9 @@ func TestGoogleProvider_Search(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGoogleProvider_Search_EmptyQuery(t *testing.T) {
|
||||
cfg := config.WebSearchProviderConfig{
|
||||
APIURL: "https://customsearch.googleapis.com/customsearch/v1?api_key=test&engine_id=test",
|
||||
}
|
||||
prov, err := NewGoogleProvider(cfg)
|
||||
setGoogleEnv("https://customsearch.googleapis.com/customsearch/v1?api_key=test&engine_id=test")
|
||||
defer unsetGoogleEnv()
|
||||
prov, err := NewGoogleProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create Google provider: %v", err)
|
||||
}
|
||||
@@ -188,10 +189,9 @@ func TestGoogleProvider_Search_NoResults(t *testing.T) {
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
cfg := config.WebSearchProviderConfig{
|
||||
APIURL: fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL),
|
||||
}
|
||||
prov, err := NewGoogleProvider(cfg)
|
||||
setGoogleEnv(fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL))
|
||||
defer unsetGoogleEnv()
|
||||
prov, err := NewGoogleProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create Google provider: %v", err)
|
||||
}
|
||||
@@ -214,10 +214,9 @@ func TestGoogleProvider_Search_ErrorResponse(t *testing.T) {
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
cfg := config.WebSearchProviderConfig{
|
||||
APIURL: fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL),
|
||||
}
|
||||
prov, err := NewGoogleProvider(cfg)
|
||||
setGoogleEnv(fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL))
|
||||
defer unsetGoogleEnv()
|
||||
prov, err := NewGoogleProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create Google provider: %v", err)
|
||||
}
|
||||
@@ -254,10 +253,9 @@ func TestGoogleProvider_Search_MaxResults(t *testing.T) {
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
cfg := config.WebSearchProviderConfig{
|
||||
APIURL: fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL),
|
||||
}
|
||||
prov, err := NewGoogleProvider(cfg)
|
||||
setGoogleEnv(fmt.Sprintf("%s/customsearch/v1?api_key=test-key&engine_id=test-engine-id", ts.URL))
|
||||
defer unsetGoogleEnv()
|
||||
prov, err := NewGoogleProvider()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create Google provider: %v", err)
|
||||
}
|
||||
|
||||
@@ -662,4 +662,9 @@ func registerWebSearchProviders(registry *web_search.Registry) {
|
||||
registry.Register(web_search.GoogleProviderInfo(), func() (interfaces.WebSearchProvider, error) {
|
||||
return web_search.NewGoogleProvider()
|
||||
})
|
||||
|
||||
// Register Bing provider
|
||||
registry.Register(web_search.BingProviderInfo(), func() (interfaces.WebSearchProvider, error) {
|
||||
return web_search.NewBingProvider()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user