Class: SharedTools::Tools::Browser::PageInspectTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::Browser::PageInspectTool
- Includes:
- InspectUtils
- Defined in:
- lib/shared_tools/tools/browser/page_inspect_tool.rb
Overview
A browser automation tool for viewing the full HTML of the page.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(summarize: false) ⇒ Object
-
#initialize(driver: nil, logger: nil) ⇒ PageInspectTool
constructor
A new instance of PageInspectTool.
Methods included from InspectUtils
#add_elements_from_matching_labels, #ci_contains, #clean_document, #cleaned_document, #find_elements_with_matching_text
Constructor Details
#initialize(driver: nil, logger: nil) ⇒ PageInspectTool
Returns a new instance of PageInspectTool.
24 25 26 27 |
# File 'lib/shared_tools/tools/browser/page_inspect_tool.rb', line 24 def initialize(driver: nil, logger: nil) @driver = driver || default_driver @logger = logger || RubyLLM.logger end |
Class Method Details
.name ⇒ Object
14 |
# File 'lib/shared_tools/tools/browser/page_inspect_tool.rb', line 14 def self.name = 'browser_page_inspect' |
Instance Method Details
#execute(summarize: false) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shared_tools/tools/browser/page_inspect_tool.rb', line 29 def execute(summarize: false) raise LoadError, "PageInspectTool requires the 'nokogiri' gem. Install it with: gem install nokogiri" unless defined?(Nokogiri) @logger.info("#{self.class.name}##{__method__}") doc = cleaned_document(html: @driver.html) if summarize PageInspect::HtmlSummarizer.summarize_interactive_elements(doc) else doc.to_html end end |