Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeURL ¶
NormalizeURL defaults a missing scheme to https so callers can pass a bare host
Types ¶
type Config ¶
type Config struct {
Enabled bool `json:"enabled" mapstructure:"enabled"`
DefaultMode string `json:"default_mode" mapstructure:"default_mode"`
Timeout time.Duration `json:"timeout" mapstructure:"timeout"`
MaxBytes int `json:"max_bytes" mapstructure:"max_bytes"`
MaxConcurrent int `json:"max_concurrent" mapstructure:"max_concurrent"`
AllowPrivateNetworks bool `json:"allow_private_networks" mapstructure:"allow_private_networks"`
}
func DefaultConfig ¶
func DefaultConfig() Config
func (Config) BatchTimeout ¶
BatchTimeout derives the wall-clock ceiling for enriching one search response (extract=true) from the per-URL budget. Workers run in ceil(count/MaxConcurrent) waves; each worker's worst case is a raw fetch plus a rendered escalation, so a single Extract is bounded by 2*Timeout. This keeps the batch bound an explicit consequence of Timeout rather than a separate knob that can drift out of sync.
func (Config) Normalized ¶
type ExtractMeta ¶
type ExtractRequest ¶
type ExtractRequest struct {
URL string
Mode Mode
ProxyURL string
LangCode string
Timeout time.Duration
MaxBytes int
// FullPage selects whole-readable-body extraction instead of the default
// article-only (trafilatura) extraction. LLM agents fetching arbitrary URLs
// often want the full page; FullPage keeps nav/feature/landing content that
// trafilatura strips. The zero value (false) preserves the cleaned default.
FullPage bool
// UseLLMSTxt, when set and the URL is a site root, probes /llms-full.txt then
// /llms.txt and returns that LLM-optimized markdown instead of scraping HTML.
UseLLMSTxt bool
// MinRunes is the per-request auto-mode escalation floor: raw output below
// this many extracted-text runes escalates to a render. 0 uses defaultMinRunes.
MinRunes int
}
type ExtractResult ¶
type ExtractResult struct {
URL string `json:"url"`
Title string `json:"title"`
Description string `json:"description"`
Markdown string `json:"markdown"`
Text string `json:"text"`
Headings []Heading `json:"headings,omitempty"`
Links []Link `json:"links,omitempty"`
Canonical string `json:"canonical,omitempty"`
Lang string `json:"lang,omitempty"`
SchemaOrg []json.RawMessage `json:"schema_org,omitempty"`
OGTags map[string]string `json:"og_tags,omitempty"`
Meta ExtractMeta `json:"meta"`
}
type Extractor ¶
type Extractor struct {
RawFetch RawFetcher
RenderedFetch RenderedFetcher
Cfg Config
}
func (*Extractor) Extract ¶
func (e *Extractor) Extract(ctx context.Context, req ExtractRequest) (*ExtractResult, error)
type FetchResponse ¶
type RawFetcher ¶
type RawFetcher func(ctx context.Context, req ExtractRequest) (*FetchResponse, error)
type RenderedFetcher ¶
type RenderedFetcher func(ctx context.Context, req ExtractRequest) (*FetchResponse, error)
Click to show internal directories.
Click to hide internal directories.