Documentation
¶
Overview ¶
Package webfetch provides a gollem.ToolSet that fetches a web page, extracts its text content, and optionally screens it for indirect prompt injection via an injected LLM client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*ToolSet)
Option configures a ToolSet.
func WithAllowPrivateIP ¶ added in v0.2.0
WithAllowPrivateIP controls the SSRF guard on the default HTTP client. The guard is enabled by default (allow == false): connections to non-public IPs (loopback, RFC1918/ULA private ranges, CGNAT, link-local metadata endpoints, etc.) are rejected at dial time on every redirect hop. Pass true to disable it, e.g. to reach a loopback test server. This has no effect when a client is injected via WithHTTPClient.
func WithHTTPClient ¶
WithHTTPClient overrides the HTTP client used for requests. A nil value is ignored and the default client is kept.
An injected client carries its own transport, so the built-in SSRF guard (see WithAllowPrivateIP) is NOT installed on it. Supplying a client is the documented escape hatch for callers that need full control over dialing.
func WithLLMClient ¶
WithLLMClient injects an LLM client for the analyze step. When set, each web_fetch call passes the extracted text through an indirect-prompt-injection analysis session and returns the cleaned Markdown on success. When nil or not provided, the analyze step is disabled and the raw extracted text is returned verbatim.
func WithLogger ¶
WithLogger sets the logger. A nil argument keeps the default (slog.Default()).
func WithMaxContentBytes ¶
WithMaxContentBytes sets the maximum number of bytes that will be read from an HTTP response body. Responses longer than this limit are truncated before extraction. The default is 10 MiB. A value <= 0 is ignored.
type ToolSet ¶
type ToolSet struct {
// contains filtered or unexported fields
}
ToolSet implements gollem.ToolSet for web-page fetching with optional LLM-based indirect prompt injection analysis. All fields are unexported; configure via Option.
func New ¶
New constructs a ToolSet. It performs only static validation; no network I/O is performed. Use Ping to verify connectivity.
func (*ToolSet) Ping ¶
Ping checks whether the configured dependencies are reachable. If an LLM client is set, it creates a session and performs a trivial generate call to confirm the client is operational; if no client is set, Ping always returns nil (the tool still works in fetch-only mode).