fix(tools): adapt Bocha search to upstream NewWebSearchTool signature change

NewWebSearchTool now returns (*WebSearchTool, error). Update Bocha
provider initialization and test call sites to handle the new signature.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shikihane 2026-03-03 13:02:21 +08:00
parent 295c0186f6
commit a6682b8ba9
2 changed files with 9 additions and 3 deletions

View file

@ -564,7 +564,7 @@ func NewWebSearchTool(opts WebSearchToolOptions) (*WebSearchTool, error) {
} else if opts.BochaEnabled && opts.BochaAPIKey != "" {
bochaClient, err := createHTTPClient(opts.Proxy, 15*time.Second)
if err != nil {
return nil
return nil, err
}
provider = &BochaSearchProvider{
apiKey: opts.BochaAPIKey,

View file

@ -731,12 +731,15 @@ func TestWebTool_BochaSearch_Success(t *testing.T) {
}))
defer server.Close()
tool := NewWebSearchTool(WebSearchToolOptions{
tool, err := NewWebSearchTool(WebSearchToolOptions{
BochaEnabled: true,
BochaAPIKey: "test-bocha-key",
BochaBaseURL: server.URL,
BochaMaxResults: 5,
})
if err != nil {
t.Fatalf("NewWebSearchTool failed: %v", err)
}
ctx := context.Background()
result := tool.Execute(ctx, map[string]any{"query": "test query"})
@ -775,11 +778,14 @@ func TestWebTool_BochaSearch_APIError(t *testing.T) {
}))
defer server.Close()
tool := NewWebSearchTool(WebSearchToolOptions{
tool, err := NewWebSearchTool(WebSearchToolOptions{
BochaEnabled: true,
BochaAPIKey: "bad-key",
BochaBaseURL: server.URL,
})
if err != nil {
t.Fatalf("NewWebSearchTool failed: %v", err)
}
ctx := context.Background()
result := tool.Execute(ctx, map[string]any{"query": "test"})