Documentation
¶
Overview ¶
Package pipeline provides the experimental portable document parsing runtime.
Runtime owns deterministic orchestration, extraction policies, diagnostics, caching and artifact formatting. Hosts explicitly provide document loading, section splitting and model execution; the package never discovers provider credentials, product configuration or concrete backends.
Index ¶
- func DetectChaptersPriority(ctx context.Context, model Model, pages []string, modelName string, ...) (map[string][]int, error)
- type ArtifactPolicy
- type Dependencies
- type DetectOptions
- type DocumentExtractionMode
- type DocumentLoader
- type DocumentLoaderFunc
- type ExtractRequest
- type ExtractedDocument
- type Model
- type ModelFunc
- type ModelRequest
- type Observer
- type ObserverFunc
- type Options
- type PDFParseMode
- type ParseBudget
- type ParseCacheOptions
- type ParseCachePolicy
- type ParseRequest
- type RetryOptions
- type Runtime
- type SectionRequest
- type Sectioner
- type SectionerFunc
- type StageEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectChaptersPriority ¶
func DetectChaptersPriority(ctx context.Context, model Model, pages []string, modelName string, spec *configs.DocSpec, opt *DetectOptions) (map[string][]int, error)
DetectChaptersPriority uses priority groups and bounded parallel batches to identify 1-based chapter pages with an explicitly supplied model adapter.
Types ¶
type ArtifactPolicy ¶
type ArtifactPolicy string
const ( ArtifactPolicyDefault ArtifactPolicy = "" ArtifactPolicyFull ArtifactPolicy = "full" ArtifactPolicySummary ArtifactPolicy = "summary" ArtifactPolicyNone ArtifactPolicy = "none" )
type Dependencies ¶
type Dependencies struct {
Loader DocumentLoader
Sectioner Sectioner
Model Model
Observer Observer
}
Dependencies are the explicit construction seam for the document Runtime.
type DetectOptions ¶
type DetectOptions struct {
// Groups 按优先级分组的章节 key 列表,groups[0] 为最高优先级。
// 若为空,将根据常见年报章节推导一个默认分组,并把未出现的章节置于最后一组。
Groups [][]string
// HeaderLines 页眉行数(默认使用 spec.Meta.HeaderLines)
HeaderLines int
// LineClip 每行最大字符数(默认 120)
LineClip int
// BatchPages 每个批次包含的页数(默认 100)
BatchPages int
// MaxConcurrent 最大并发批次数(默认 3)
MaxConcurrent int
// RetryOptions LLM 重试参数(为空则使用章节识别的默认:90s/1次重试/3m总时长)
RetryOptions *RetryOptions
}
DetectOptions 控制优先级分组与并发等参数
type DocumentExtractionMode ¶
type DocumentExtractionMode string
DocumentExtractionMode controls the preferred source order used by the host document loader.
const ( DocumentExtractionModeDefault DocumentExtractionMode = "" DocumentExtractionModeLegacy DocumentExtractionMode = "legacy" DocumentExtractionModeTableFirst DocumentExtractionMode = "table_first" DocumentExtractionModeTextLayerFirst DocumentExtractionMode = "text_layer_first" DocumentExtractionModeOCRFirst DocumentExtractionMode = "ocr_first" DocumentExtractionModeAuto DocumentExtractionMode = "auto" )
func NormalizeDocumentExtractionMode ¶
func NormalizeDocumentExtractionMode(raw string) (DocumentExtractionMode, error)
NormalizeDocumentExtractionMode normalizes documented aliases without selecting a concrete extractor.
type DocumentLoader ¶
type DocumentLoader interface {
Extract(context.Context, ExtractRequest) (*ExtractedDocument, error)
}
DocumentLoader supplies file decoding, OCR selection and concrete PDF access.
type DocumentLoaderFunc ¶
type DocumentLoaderFunc func(context.Context, ExtractRequest) (*ExtractedDocument, error)
DocumentLoaderFunc adapts a function to DocumentLoader.
func (DocumentLoaderFunc) Extract ¶
func (f DocumentLoaderFunc) Extract(ctx context.Context, req ExtractRequest) (*ExtractedDocument, error)
type ExtractRequest ¶
type ExtractRequest struct {
Path string
PageLimit int
PDFParseMode PDFParseMode
ExtractionMode DocumentExtractionMode
}
ExtractRequest describes a host-owned document extraction operation.
type ExtractedDocument ¶
type ExtractedDocument struct {
Pages []string
TextSource string
PDFResponse *pdfparser.TableResponse
}
ExtractedDocument is the substrate-neutral result consumed by Runtime.
type Model ¶
type Model interface {
Complete(context.Context, ModelRequest) (string, error)
}
Model is the only model capability required by Runtime. Provider selection, credentials, authorization, networking and retry execution remain host-owned.
type ModelFunc ¶
type ModelFunc func(context.Context, ModelRequest) (string, error)
ModelFunc adapts a function to Model.
type ModelRequest ¶
type ModelRequest struct {
ModelName string
Prompt string
Chunks []string
Retry RetryOptions
}
ModelRequest is one text completion required by document coordination.
type Observer ¶
type Observer interface {
Observe(context.Context, StageEvent)
}
Observer receives optional runtime progress without controlling behavior.
type ObserverFunc ¶
type ObserverFunc func(context.Context, StageEvent)
ObserverFunc adapts a function to Observer.
func (ObserverFunc) Observe ¶
func (f ObserverFunc) Observe(ctx context.Context, event StageEvent)
type Options ¶
type Options struct {
ModelName string
OutputDir string // Optional. Empty output dirs are allocated under the system temp directory.
MaxChunkChars int // 默认 12000
PDFParseMode *PDFParseMode
ExtractionMode *DocumentExtractionMode
ArtifactPolicy ArtifactPolicy
}
type PDFParseMode ¶
type PDFParseMode int
PDFParseMode controls the host document loader's PDF extraction strategy.
const ( PDFParseSimple PDFParseMode = iota PDFParseNormal PDFParseForceOCR )
type ParseBudget ¶
type ParseCacheOptions ¶
type ParseCacheOptions struct {
Policy ParseCachePolicy
Dir string
}
type ParseCachePolicy ¶
type ParseCachePolicy string
const ( ParseCachePolicyDefault ParseCachePolicy = "" ParseCachePolicyNone ParseCachePolicy = "none" ParseCachePolicyRead ParseCachePolicy = "read" ParseCachePolicyWrite ParseCachePolicy = "write" ParseCachePolicyReadWrite ParseCachePolicy = "read_write" )
type ParseRequest ¶
type ParseRequest struct {
DocPath string
SpecPath string
ModelName string
OutputDir string
MaxChunkChars int
PageLimit int
PDFParseMode *PDFParseMode
ExtractionMode *DocumentExtractionMode
ArtifactPolicy ArtifactPolicy
Cache ParseCacheOptions
TraceMode string
Budget ParseBudget
}
type RetryOptions ¶
type RetryOptions struct {
MaxRetries int
AttemptTimeout time.Duration
TotalTimeout time.Duration
BackoffBase time.Duration
BackoffMultiplier float64
BackoffJitter float64
}
RetryOptions communicates the legacy-compatible retry intent to a host model adapter. The portable pipeline never discovers providers or credentials and does not own network retry policy.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime coordinates the portable document pipeline over host-provided I/O. It is safe for concurrent Run calls when the injected dependencies are safe.
func New ¶
func New(deps Dependencies) (*Runtime, error)
New constructs a Runtime without discovering host configuration.
func (*Runtime) ParseDocument ¶
func (r *Runtime) ParseDocument(docPath, specPath string, opts Options) (*types.DocumentResult, error)
ParseDocument preserves the concise legacy-shaped call on an explicitly constructed Runtime.
func (*Runtime) Run ¶
func (r *Runtime) Run(ctx context.Context, req ParseRequest) (*types.DocumentResult, error)
Run executes the portable document pipeline with explicit host dependencies.
type SectionRequest ¶
SectionRequest is the complete input to a host-provided section splitter.
type Sectioner ¶
Sectioner owns the concrete section-rule backend while returning portable section trees to Runtime.
type SectionerFunc ¶
SectionerFunc adapts a function to Sectioner.
func (SectionerFunc) Split ¶
func (f SectionerFunc) Split(ctx context.Context, req SectionRequest) ([]*section.Node, error)
type StageEvent ¶
StageEvent is a display-safe observation emitted at a major pipeline boundary.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
logging
Package logging contains intentionally silent logging hooks for deterministic document helpers.
|
Package logging contains intentionally silent logging hooks for deterministic document helpers. |
|
Package section defines the substrate-neutral section tree exchanged between the document pipeline and a host-provided section splitter.
|
Package section defines the substrate-neutral section tree exchanged between the document pipeline and a host-provided section splitter. |