Class: SharedTools::Tools::Browser::PageScreenshotTool

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/shared_tools/tools/browser/page_screenshot_tool.rb

Overview

A browser automation tool for taking screenshots of the current page.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver: nil, logger: nil) ⇒ PageScreenshotTool

Returns a new instance of PageScreenshotTool.



14
15
16
17
# File 'lib/shared_tools/tools/browser/page_screenshot_tool.rb', line 14

def initialize(driver: nil, logger: nil)
  @driver = driver || default_driver
  @logger = logger || RubyLLM.logger
end

Class Method Details

.nameObject



10
# File 'lib/shared_tools/tools/browser/page_screenshot_tool.rb', line 10

def self.name = 'browser_page_screenshot'

Instance Method Details

#executeObject



19
20
21
22
23
24
25
# File 'lib/shared_tools/tools/browser/page_screenshot_tool.rb', line 19

def execute
  @logger.info("#{self.class.name}##{__method__}")

  @driver.screenshot do |file|
    "data:image/png;base64,#{Base64.strict_encode64(file.read)}"
  end
end