blob: a540c8fe39aab9d853b356de5f418210675eb7f9 [file] [log] [blame]
package browse
import (
"context"
"log"
"sketch.dev/llm"
)
// RegisterBrowserTools initializes the browser tools and returns all the tools
// ready to be added to an agent. It also returns a cleanup function that should
// be called when done to properly close the browser.
func RegisterBrowserTools(ctx context.Context) ([]*llm.Tool, func()) {
browserTools := NewBrowseTools(ctx)
// Initialize the browser
if err := browserTools.Initialize(); err != nil {
log.Printf("Warning: Failed to initialize browser: %v", err)
}
// Return all tools and a cleanup function
return browserTools.GetAllTools(), func() {
browserTools.Close()
}
}
// Tool is an alias for llm.Tool to make the documentation clearer
type Tool = llm.Tool