Class: Nanobot::Agent::Tools::WebFetch
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Nanobot::Agent::Tools::WebFetch
- Defined in:
- lib/nanobot/agent/tools/web.rb
Overview
Tool for fetching and parsing web pages
Constant Summary collapse
- MAX_RESPONSE_BYTES =
1 MB
1_048_576- OPEN_TIMEOUT =
10- READ_TIMEOUT =
15- MAX_REDIRECTS =
5- PRIVATE_RANGES =
[ IPAddr.new('0.0.0.0/8'), IPAddr.new('127.0.0.0/8'), IPAddr.new('10.0.0.0/8'), IPAddr.new('172.16.0.0/12'), IPAddr.new('192.168.0.0/16'), IPAddr.new('169.254.0.0/16'), IPAddr.new('::1/128'), IPAddr.new('fc00::/7'), IPAddr.new('fe80::/10') ].freeze
- USER_AGENT =
'Mozilla/5.0 (compatible)'
Instance Method Summary collapse
-
#execute(url:) ⇒ String
Fetch a web page, validate its URL, and return parsed content.
Instance Method Details
#execute(url:) ⇒ String
Fetch a web page, validate its URL, and return parsed content.
114 115 116 117 118 119 120 |
# File 'lib/nanobot/agent/tools/web.rb', line 114 def execute(url:) validate_url!(url) content = fetch(url) parse_content(content, url) rescue StandardError => e "Error fetching web page: #{e.}" end |