browseruse

package module
v0.0.0-...-c9a5dc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 1

README

BrowserUse Tool

A BrowserUse Tool implementation for Eino that implements the Tool interface. This enables seamless integration with Eino's LLM capabilities for enhanced natural language processing and generation.

Note: This implementation is inspired by and references the OpenManus project.

Features

  • Implements github.com/cloudwego/eino/components/tool.BaseTool
  • Easy integration with Eino's tool system
  • Support for executing browser actions

Installation

go get github.com/cloudwego/eino-ext/components/tool/browseruse@latest

Quick Start

Here's a quick example of how to use the browser-use tool:

package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/cloudwego/eino-ext/components/tool/browseruse"
)

func main() {
	ctx := context.Background()
	but, err := browseruse.NewBrowserUseTool(ctx, &browseruse.Config{})
	if err != nil {
		log.Fatal(err)
	}

	url := "https://www.google.com"
	result, err := but.Execute(&browseruse.Param{
		Action: browseruse.ActionGoToURL,
		URL:    &url,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(result)
	time.Sleep(10 * time.Second)
	but.Cleanup()
}

Examples

See the examples directory for complete usage examples.

For More Details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	ActionGoToURL      Action = "go_to_url"
	ActionClickElement Action = "click_element"
	ActionInputText    Action = "input_text"
	ActionScrollDown   Action = "scroll_down"
	ActionScrollUp     Action = "scroll_up"
	//ActionSendKeys       Action = "send_keys"
	ActionWebSearch      Action = "web_search"
	ActionWait           Action = "wait"
	ActionExtractContent Action = "extract_content"
	ActionSwitchTab      Action = "switch_tab"
	ActionOpenTab        Action = "open_tab"
	ActionCloseTab       Action = "close_tab"
)

type BrowserState

type BrowserState struct {
	URL                 string     `json:"url"`
	Title               string     `json:"title"`
	Tabs                []TabInfo  `json:"tabs"`
	InteractiveElements string     `json:"interactive_elements"`
	ScrollInfo          ScrollInfo `json:"scroll_info"`
	ViewportHeight      int        `json:"viewport_height"`
	Screenshot          string     `json:"screenshot"`
}

type Config

type Config struct {
	Headless           bool     `json:"headless"`
	DisableSecurity    bool     `json:"disable_security"`
	ExtraChromiumArgs  []string `json:"extra_chromium_args"`
	ChromeInstancePath string   `json:"chrome_instance_path"`
	ProxyServer        string   `json:"proxy_server"`

	DDGSearchTool    duckduckgo.Search
	ExtractChatModel model.BaseChatModel

	Logf func(string, ...any)
}

type ElementInfo

type ElementInfo struct {
	Index       int    `json:"index"`
	Description string `json:"description"`
	Type        string `json:"type"`
	XPath       string `json:"xpath"`
}

type Param

type Param struct {
	Action Action `json:"action"`

	URL          *string `json:"url,omitempty"`
	Index        *int    `json:"index,omitempty"`
	Text         *string `json:"text,omitempty"`
	ScrollAmount *int    `json:"scroll_amount,omitempty"`
	TabID        *int    `json:"tab_id,omitempty"`
	Query        *string `json:"query,omitempty"`
	Goal         *string `json:"goal,omitempty"`
	Keys         *string `json:"keys,omitempty"`
	Seconds      *int    `json:"seconds,omitempty"`
}

type ScrollInfo

type ScrollInfo struct {
	PixelsAbove int `json:"pixels_above"`
	PixelsBelow int `json:"pixels_below"`
	TotalHeight int `json:"total_height"`
}

type TabInfo

type TabInfo struct {
	ID       int       `json:"id"`
	TargetID target.ID `json:"target_id"`
	Title    string    `json:"title"`
	URL      string    `json:"url"`
}

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

func NewBrowserUseTool

func NewBrowserUseTool(ctx context.Context, config *Config) (*Tool, error)

func (*Tool) Cleanup

func (b *Tool) Cleanup()

func (*Tool) Execute

func (b *Tool) Execute(params *Param) (*ToolResult, error)

func (*Tool) GetCurrentState

func (b *Tool) GetCurrentState() (*BrowserState, error)

func (*Tool) Info

func (b *Tool) Info(_ context.Context) (*schema.ToolInfo, error)

func (*Tool) InvokableRun

func (b *Tool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)

type ToolResult

type ToolResult struct {
	Output      string `json:"output,omitempty"`
	Error       string `json:"error,omitempty"`
	Base64Image string `json:"base64_image,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL