data/tools/web_fetch_tool library
Classes
- InvalidUrl
- UrlValidation
- URL validation result.
- ValidUrl
- WebFetchInput
- Web fetch input.
- WebFetchOutput
- Web fetch output.
Constants
- cacheTtl → const Duration
- Cache TTL for fetched content.
- domainCheckTimeout → const Duration
- Domain check timeout.
- fetchTimeout → const Duration
- Fetch timeout.
- maxCacheSize → const int
- Maximum cache size in bytes.
- maxHttpContentLength → const int
- Maximum HTTP content size (10MB).
- maxMarkdownLength → const int
- Maximum markdown content length before truncation.
- maxRedirects → const int
- Maximum redirect hops.
- maxUrlLength → const int
- Maximum URL length.
-
preapprovedHosts
→ const Set<
String> - Preapproved hosts for web fetching (no copyright restrictions).
Functions
-
copyrightPrompt(
String markdown, String userPrompt) → String - Prompt for non-preapproved domains (copyright restrictions).
-
fetchUrl(
WebFetchInput input, {Future< String> applyPrompt(String systemPrompt, String userPrompt)?, HttpClient? httpClient}) → Future<WebFetchOutput> - Fetch and process a URL with the WebFetchTool semantics.
-
htmlToMarkdown(
String html) → String - Convert HTML content to clean markdown.
-
isBinaryContentType(
String contentType) → bool - Check if a content type is binary.
-
isPermittedRedirect(
Uri original, Uri redirect) → bool - Check if a redirect is permitted.
-
isPreapprovedUrl(
Uri uri) → bool - Check if a URL is preapproved.
-
preapprovedPrompt(
String markdown, String userPrompt) → String - Prompt for preapproved domains (allows full extraction).
-
validateUrl(
String urlString) → UrlValidation - Validate a URL for fetching.