Documentation
¶
Index ¶
- func GenerateSchema(typeDefinition interface{}) string
- func RegisterAction[T, D any](c *Controller, name string, description string, ...) error
- func ValidateSchema(schemaString string, data map[string]interface{}) error
- type ActModel
- type ActionModel
- type ActionRegistry
- type ActionResult
- type ClickElementAction
- type CloseTabAction
- type Controller
- func (c *Controller) ClickElementByIndex(ctx context.Context, params ClickElementAction) (*ActionResult, error)
- func (c *Controller) CloseTab(ctx context.Context, params CloseTabAction) (*ActionResult, error)
- func (c *Controller) Done(_ context.Context, params DoneAction) (*ActionResult, error)
- func (c *Controller) DragDrop(ctx context.Context, params DragDropAction) (*ActionResult, error)
- func (c *Controller) ExecuteAction(action *ActModel, browserContext *browser.BrowserContext, ...) (*ActionResult, error)
- func (c *Controller) ExtractContent(ctx context.Context, params ExtractContentAction) (*ActionResult, error)
- func (c *Controller) GetDropdownOptions(ctx context.Context, params GetDropdownOptionsAction) (*ActionResult, error)
- func (c *Controller) GoBack(ctx context.Context, params GoBackAction) (*ActionResult, error)
- func (c *Controller) GoToUrl(ctx context.Context, params GoToUrlAction) (*ActionResult, error)
- func (c *Controller) InputText(ctx context.Context, params InputTextAction) (*ActionResult, error)
- func (c *Controller) OpenTab(ctx context.Context, params OpenTabAction) (*ActionResult, error)
- func (c *Controller) SavePdf(ctx context.Context, params SavePdfAction) (*ActionResult, error)
- func (c *Controller) ScrollDown(ctx context.Context, params ScrollDownAction) (*ActionResult, error)
- func (c *Controller) ScrollToText(ctx context.Context, params ScrollToTextAction) (*ActionResult, error)
- func (c *Controller) ScrollUp(ctx context.Context, params ScrollUpAction) (*ActionResult, error)
- func (c *Controller) SearchGoogle(ctx context.Context, params SearchGoogleAction) (*ActionResult, error)
- func (c *Controller) SelectDropdownOption(ctx context.Context, params SelectDropdownOptionAction) (*ActionResult, error)
- func (this *Controller) SendKeys(ctx context.Context, params SendKeysAction) (*ActionResult, error)
- func (c *Controller) SwitchTab(ctx context.Context, params SwitchTabAction) (*ActionResult, error)
- func (c *Controller) Wait(ctx context.Context, params WaitAction) (*ActionResult, error)
- type DoneAction
- type DragDropAction
- type ExtractContentAction
- type ExtractPageContentAction
- type GetDropdownOptionsAction
- type GoBackAction
- type GoToUrlAction
- type GroupTabsAction
- type InputTextAction
- type NoParamsAction
- type OpenTabAction
- type Position
- type RegisteredAction
- type Registry
- type SavePdfAction
- type ScrollDownAction
- type ScrollToTextAction
- type ScrollUpAction
- type SearchGoogleAction
- type SelectDropdownOptionAction
- type SendKeysAction
- type SwitchTabAction
- type UngroupTabsAction
- type WaitAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSchema ¶
func GenerateSchema(typeDefinition interface{}) string
func RegisterAction ¶
func RegisterAction[T, D any]( c *Controller, name string, description string, function einoUtils.InvokeFunc[T, D], domains []string, pageFilter func(playwright.Page) bool, ) error
func ValidateSchema ¶
Types ¶
type ActionModel ¶
type ActionModel struct { /* * this will have all the registered actions, e.g. * click_element_by_index = param_model = ClickElementParams * done = param_model = nil */ Actions map[string]*RegisteredAction `json:"actions"` }
Base model for dynamically created action models
type ActionRegistry ¶
type ActionRegistry struct {
Actions map[string]*RegisteredAction
}
Model representing the action registry
func NewActionRegistry ¶
func NewActionRegistry() *ActionRegistry
func (*ActionRegistry) GetPromptDescription ¶
func (ar *ActionRegistry) GetPromptDescription(page playwright.Page) string
Get a description of all actions for the prompt
type ActionResult ¶
type ActionResult struct { IsDone *bool `json:"is_done,omitempty"` Success *bool `json:"success,omitempty"` ExtractedContent *string `json:"extracted_content,omitempty"` Error *string `json:"error,omitempty"` IncludeInMemory bool `json:"include_in_memory"` }
func NewActionResult ¶
func NewActionResult() *ActionResult
type ClickElementAction ¶
type CloseTabAction ¶
type CloseTabAction struct {
PageId int `json:"page_id"`
}
type Controller ¶
type Controller struct {
Registry *Registry
}
func NewController ¶
func NewController() *Controller
func (*Controller) ClickElementByIndex ¶
func (c *Controller) ClickElementByIndex(ctx context.Context, params ClickElementAction) (*ActionResult, error)
ExecuteAction: action.Function(validatedParams, extraArgs)
func (*Controller) CloseTab ¶
func (c *Controller) CloseTab(ctx context.Context, params CloseTabAction) (*ActionResult, error)
func (*Controller) Done ¶
func (c *Controller) Done(_ context.Context, params DoneAction) (*ActionResult, error)
func (*Controller) DragDrop ¶
func (c *Controller) DragDrop(ctx context.Context, params DragDropAction) (*ActionResult, error)
Performs a precise drag and drop operation between elements or coordinates.
func (*Controller) ExecuteAction ¶
func (c *Controller) ExecuteAction( action *ActModel, browserContext *browser.BrowserContext, pageExtractionLlm model.ToolCallingChatModel, sensitiveData map[string]string, availableFilePaths []string, ) (*ActionResult, error)
Act
func (*Controller) ExtractContent ¶
func (c *Controller) ExtractContent(ctx context.Context, params ExtractContentAction) (*ActionResult, error)
func (*Controller) GetDropdownOptions ¶
func (c *Controller) GetDropdownOptions(ctx context.Context, params GetDropdownOptionsAction) (*ActionResult, error)
func (*Controller) GoBack ¶
func (c *Controller) GoBack(ctx context.Context, params GoBackAction) (*ActionResult, error)
func (*Controller) GoToUrl ¶
func (c *Controller) GoToUrl(ctx context.Context, params GoToUrlAction) (*ActionResult, error)
func (*Controller) InputText ¶
func (c *Controller) InputText(ctx context.Context, params InputTextAction) (*ActionResult, error)
func (*Controller) OpenTab ¶
func (c *Controller) OpenTab(ctx context.Context, params OpenTabAction) (*ActionResult, error)
func (*Controller) SavePdf ¶
func (c *Controller) SavePdf(ctx context.Context, params SavePdfAction) (*ActionResult, error)
func (*Controller) ScrollDown ¶
func (c *Controller) ScrollDown(ctx context.Context, params ScrollDownAction) (*ActionResult, error)
func (*Controller) ScrollToText ¶
func (c *Controller) ScrollToText(ctx context.Context, params ScrollToTextAction) (*ActionResult, error)
func (*Controller) ScrollUp ¶
func (c *Controller) ScrollUp(ctx context.Context, params ScrollUpAction) (*ActionResult, error)
func (*Controller) SearchGoogle ¶
func (c *Controller) SearchGoogle(ctx context.Context, params SearchGoogleAction) (*ActionResult, error)
func (*Controller) SelectDropdownOption ¶
func (c *Controller) SelectDropdownOption(ctx context.Context, params SelectDropdownOptionAction) (*ActionResult, error)
func (*Controller) SendKeys ¶
func (this *Controller) SendKeys(ctx context.Context, params SendKeysAction) (*ActionResult, error)
func (*Controller) SwitchTab ¶
func (c *Controller) SwitchTab(ctx context.Context, params SwitchTabAction) (*ActionResult, error)
func (*Controller) Wait ¶
func (c *Controller) Wait(ctx context.Context, params WaitAction) (*ActionResult, error)
type DoneAction ¶
type DragDropAction ¶
type DragDropAction struct { // Element-based approach ElementSource *string `json:"element_source,omitempty" jsonschema:"anyof_type=string;null,default=null"` ElementTarget *string `json:"element_target,omitempty" jsonschema:"anyof_type=string;null,default=null"` ElementSourceOffset *Position `json:"element_source_offset,omitempty" jsonschema:"anyof_type=object;null,default=null"` ElementTargetOffset *Position `json:"element_target_offset,omitempty" jsonschema:"anyof_type=object;null,default=null"` // Coordinate-based approach (used if selectors not provided) CoordSourceX *int `json:"coord_source_x,omitempty" jsonschema:"anyof_type=integer;null,default=null"` CoordSourceY *int `json:"coord_source_y,omitempty" jsonschema:"anyof_type=integer;null,default=null"` CoordTargetX *int `json:"coord_target_x,omitempty" jsonschema:"anyof_type=integer;null,default=null"` CoordTargetY *int `json:"coord_target_y,omitempty" jsonschema:"anyof_type=integer;null,default=null"` // Common options Steps *int `json:"steps,omitempty" jsonschema:"anyof_type=integer;null,default=null"` DelayMs *int `json:"delay_ms,omitempty" jsonschema:"anyof_type=integer;null,default=null"` }
func NewDragDropAction ¶
func NewDragDropAction() *DragDropAction
type ExtractContentAction ¶
type ExtractPageContentAction ¶
type ExtractPageContentAction struct {
Value string `json:"value"`
}
type GetDropdownOptionsAction ¶
type GetDropdownOptionsAction struct {
Index int `json:"index"`
}
type GoBackAction ¶
type GoBackAction struct { }
type GoToUrlAction ¶
type GoToUrlAction struct {
Url string `json:"url"`
}
type GroupTabsAction ¶
type InputTextAction ¶
type NoParamsAction ¶
type NoParamsAction struct { }
func (NoParamsAction) IgnoreAllInputs ¶
func (NoParamsAction) IgnoreAllInputs(values map[string]interface{}) *NoParamsAction
type OpenTabAction ¶
type OpenTabAction struct {
Url string `json:"url"`
}
type RegisteredAction ¶
type RegisteredAction struct { Tool *tool.InvokableTool // filters: provide specific domains or a function to determine whether the action should be available on the given page or not Domains []string // # e.g. ['*.google.com', 'www.bing.com', 'yahoo.*] PageFilter func(playwright.Page) bool }
func NewRegisteredAction ¶
func NewRegisteredAction[T, D any]( name string, description string, actionFunc einoUtils.InvokeFunc[T, D], domains []string, pageFilter func(playwright.Page) bool, ) (*RegisteredAction, error)
func (*RegisteredAction) PromptDescription ¶
func (ra *RegisteredAction) PromptDescription() string
example
----------------- INPUT ------------------------------ description: "Search for text" name: "search" param_model:
class SearchParams(BaseModel): query: str case_sensitive: bool { "query": {"type": "string", "title": "검색어"}, "case_sensitive": {"type": "boolean", "title": "대소문자 구분"} }
----------------- OUTPUT ------------------------------ Search for text: {search: {'query': {'type': 'string'}, 'case_sensitive': {'type': 'boolean'}}}
type Registry ¶
type Registry struct { Registry *ActionRegistry ExcludeActions []string }
The main service class that manages action registration and execution
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) CreateActionModel ¶
func (r *Registry) CreateActionModel(includeActions []string, page playwright.Page) *ActionModel
func (*Registry) ExecuteAction ¶
func (r *Registry) ExecuteAction( actionName string, argumentsInJson string, browser *browser.BrowserContext, pageExtractionLlm model.ToolCallingChatModel, sensitiveData map[string]string, availableFilePaths []string, ) (string, error)
Execute a registered action TODO(LOW): support Context
func (*Registry) GetPromptDescription ¶
type SavePdfAction ¶
type SavePdfAction struct { }
type ScrollDownAction ¶
type ScrollDownAction struct {
Amount *int `json:"amount,omitempty" jsonschema:"anyof_type=integer;null,default=null"`
}
type ScrollToTextAction ¶
type ScrollToTextAction struct {
Text string `json:"text"`
}
type ScrollUpAction ¶
type ScrollUpAction struct {
Amount *int `json:"amount,omitempty" jsonschema:"anyof_type=integer;null,default=null"`
}
type SearchGoogleAction ¶
type SearchGoogleAction struct {
Query string `json:"query"`
}
Action Input Models
type SendKeysAction ¶
type SendKeysAction struct {
Keys string `json:"keys"`
}
type SwitchTabAction ¶
type SwitchTabAction struct {
PageId int `json:"page_id"`
}
type UngroupTabsAction ¶
type UngroupTabsAction struct {
TabIds []int `json:"tab_ids"`
}
type WaitAction ¶
type WaitAction struct {
Seconds int `json:"seconds"`
}