Skip to content

Operations

The three pipeline stages. Each has a sync form and an async a-prefixed form (use the async form inside an event loop). parse is the only operation that needs the OCR server; classify and split accept either a ParseResult or a raw file path.

parse

ingestlib.operations.parse.pipeline.aparse async

aparse(path: Path | str, *, dpi: int = 200) -> ParseResult

Parse a document into a ParseResult (async).

path — PDF/DOCX/PPTX to parse dpi — page render resolution; 200 balances OCR accuracy against VLM token cost and memory

ingestlib.operations.parse.pipeline.parse

parse(path: Path | str, *, dpi: int = 200) -> ParseResult

Parse a document into a ParseResult.

Synchronous wrapper around aparse(). If you're already inside an event loop, use aparse() instead.

classify

ingestlib.operations.classify.classifier.aclassify async

aclassify(
    source: ParseResult | Path | str,
    categories: dict[str, str] | None = None,
    *,
    target_pages: str | None = None,
    max_pages: int | None = None,
) -> ClassifyResult

Classify a document's type (async).

source — a ParseResult from parse(), or a PDF/DOCX/PPTX path (no OCR run) categories — optional {snake_case_label: description}, max 20; when given, the result is one of these labels or "uncategorized". None uses rules.yaml's classify: preset; {} forces open-ended. target_pages — optional 1-based page selection like "1,3,5-7" max_pages — optional cap applied after selection (the 100-page hard cap always applies)

ingestlib.operations.classify.classifier.classify

classify(
    source: ParseResult | Path | str,
    categories: dict[str, str] | None = None,
    *,
    target_pages: str | None = None,
    max_pages: int | None = None,
) -> ClassifyResult

Classify a document's type. Sync wrapper — use aclassify() inside an event loop.

split

ingestlib.operations.split.splitter.asplit async

asplit(
    source: ParseResult | Path | str,
    *,
    category: str | None = None,
    max_chunk_tokens: int = DEFAULT_MAX_CHUNK_TOKENS,
    vocabulary: dict[str, str] | None = None,
    unmatched: str | None = None,
) -> SplitResult

Split a document into sections and natural chunks (async).

source — a ParseResult from parse(), or a PDF/DOCX/PPTX path (no OCR run) category — optional document-type label (e.g. from classify()) used in each chunk's embedding_text breadcrumb max_chunk_tokens — ceiling on chunk size; natural boundaries rule below it vocabulary — optional {section: description}, max 50; when given, Pass 1 is skipped and pages label against YOUR sections. None uses rules.yaml's split: preset; {} forces LLM discovery. unmatched — pages fitting no user category: "other" (default — an honest other section) | "require" (left-neighbor repair) | "skip" (dropped). None uses the preset.

ingestlib.operations.split.splitter.split

split(
    source: ParseResult | Path | str,
    *,
    category: str | None = None,
    max_chunk_tokens: int = DEFAULT_MAX_CHUNK_TOKENS,
    vocabulary: dict[str, str] | None = None,
    unmatched: str | None = None,
) -> SplitResult

Split a document into sections and natural chunks.

Sync wrapper — use asplit() inside an event loop.