| Philip Zeyliger | 33d282f | 2025-05-03 04:01:54 +0000 | [diff] [blame] | 1 | package browse |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| Philip Zeyliger | 33d282f | 2025-05-03 04:01:54 +0000 | [diff] [blame] | 5 | |
| 6 | "sketch.dev/llm" |
| 7 | ) |
| 8 | |
| Philip Zeyliger | 80b488d | 2025-05-10 18:21:54 -0700 | [diff] [blame] | 9 | // RegisterBrowserTools returns all browser tools ready to be added to an agent. |
| 10 | // It also returns a cleanup function that should be called when done to properly close the browser. |
| 11 | // The browser will be initialized lazily when a browser tool is first used. |
| Philip Zeyliger | 72252cb | 2025-05-10 17:00:08 -0700 | [diff] [blame] | 12 | func RegisterBrowserTools(ctx context.Context, supportsScreenshots bool) ([]*llm.Tool, func()) { |
| Philip Zeyliger | 33d282f | 2025-05-03 04:01:54 +0000 | [diff] [blame] | 13 | browserTools := NewBrowseTools(ctx) |
| 14 | |
| Philip Zeyliger | 72252cb | 2025-05-10 17:00:08 -0700 | [diff] [blame] | 15 | return browserTools.GetTools(supportsScreenshots), func() { |
| Philip Zeyliger | 33d282f | 2025-05-03 04:01:54 +0000 | [diff] [blame] | 16 | browserTools.Close() |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // Tool is an alias for llm.Tool to make the documentation clearer |
| 21 | type Tool = llm.Tool |