Class: Hellm::Tools::WebTool
- Inherits:
-
Object
- Object
- Hellm::Tools::WebTool
- Extended by:
- Langchain::ToolDefinition
- Defined in:
- lib/hellm/tools/web_tool.rb
Instance Method Summary collapse
Instance Method Details
#read(url:) ⇒ Object
16 17 18 19 20 |
# File 'lib/hellm/tools/web_tool.rb', line 16 def read(url:) URI.open(url).read rescue StandardError => e "Failed to read from URL #{url}: #{e.}" end |
#read_text(url:) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/hellm/tools/web_tool.rb', line 22 def read_text(url:) html_content = URI.open(url).read text = Nokogiri::HTML(html_content).text lines = text.lines.map(&:strip).reject(&:empty?) lines.join("\n") rescue StandardError => e "Failed to extract text from URL #{url}: #{e.}" end |