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:
parent
295c0186f6
commit
a6682b8ba9
2 changed files with 9 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue