Class: SharedTools::Tools::Browser::PageScreenshotTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::Browser::PageScreenshotTool
- Defined in:
- lib/shared_tools/tools/browser/page_screenshot_tool.rb
Overview
A browser automation tool for taking screenshots of the current page. Saves the screenshot to a file and returns the path — avoids injecting large base64 blobs into the conversation context.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(path: nil) ⇒ Object
-
#initialize(driver: nil, logger: nil) ⇒ PageScreenshotTool
constructor
A new instance of PageScreenshotTool.
Constructor Details
#initialize(driver: nil, logger: nil) ⇒ PageScreenshotTool
Returns a new instance of PageScreenshotTool.
20 21 22 23 |
# File 'lib/shared_tools/tools/browser/page_screenshot_tool.rb', line 20 def initialize(driver: nil, logger: nil) @driver = driver || default_driver @logger = logger || RubyLLM.logger end |
Class Method Details
.name ⇒ Object
10 |
# File 'lib/shared_tools/tools/browser/page_screenshot_tool.rb', line 10 def self.name = 'browser_page_screenshot' |
Instance Method Details
#execute(path: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/shared_tools/tools/browser/page_screenshot_tool.rb', line 25 def execute(path: nil) @logger.info("#{self.class.name}##{__method__}") save_path = path || "screenshot_#{Time.now.strftime('%Y%m%d_%H%M%S')}.png" @driver.screenshot do |file| File.binwrite(save_path, file.read) end { status: :ok, saved_to: File.(save_path) } end |