Documentation
    Preparing search index...

    Module @quatrain/okf-ingest

    @quatrain/okf-ingest

    Multi-source document ingestion, multimodal extraction, visual schema & Mermaid diagram transcription, token cost tracking, and Open Knowledge Format (OKF v0.2) packaging for the Quatrain ecosystem.

    • OKF v0.2 Compliant: Native support for the # --- Open Knowledge Format v0.2 --- specification, including description (1-sentence summary), status, generated: { by, at, tokens }, and sources: [...].
    • Text & Multimodal Ingestion: Extracts digital text layers via pdf-parse and falls back automatically to multimodal Gemini vision for scanned or image-dense documents.
    • Visual Synthesis & Mermaid Transcription: Instructs Gemini to transcribe process flows, decision trees, and cycles into mermaid code blocks, and matrices/comparison charts into Markdown tables.
    • Accurate Token & Cost Tracking: Computes exact input/output/thinking token usage and USD costs per document.
    • Resilient Dedup Cache: SHA-256 hash tracking with persistent token accounting and automatic sync from existing Git knowledge repos.
    yarn add @quatrain/okf-ingest
    # or
    bun add @quatrain/okf-ingest

    AGPL-3.0-only

    Classes

    AgroecologyTaxonomyProfile
    GeminiStructuredRunner
    GenericDomainProfile
    OkfDedupCache
    OkfEntryEvaluator

    Interfaces

    AiRunnerOptions
    AiRunnerResponse
    AiSourceInput
    AiStructuredRunner
    BookOutline
    BookOutlineChapter
    BookOutlinePromptParams
    ChapterExtractionResult
    ChapterFrontmatterOptions
    CompositeEvaluationReport
    CompositeJudgeOptions
    DedupEntry
    DedupStats
    DocumentPromptParams
    DomainTaxonomyField
    DomainTaxonomyProfile
    ExtractionOptions
    GeminiRunnerConfig
    IngestionExtractionResult
    JudgeProviderConfig
    ModelPricing
    MonographIngestionResult
    MonographInput
    MonographOptions
    MultimodalPart
    OkfDimensionScores
    OkfDocument
    OkfEvaluationReport
    OkfEvaluationTarget
    OkfFrontmatterV2
    OkfGenerationMetadata
    OkfHallucination
    OkfJsonSchema
    OkfJsonSchemaProperty
    OkfMultilingualContent
    OkfMultilingualKeywords
    OkfSourceEntry
    OkfTokenUsage
    PdfExtractionResult
    RawTokenUsageMetadata
    ResolveAdapterOptions
    SerializeOptions
    WriteOkfOptions

    Type Aliases

    OkfDocumentStatus
    OkfDocumentType

    Variables

    BOOK_OUTLINE_AI_SCHEMA
    GEMINI_MODEL_PRICING
    LANGUAGE_SYNTHESIS_DESCRIPTIONS
    OKF_BASE_PROPERTIES
    OKF_DIAGRAMS_SCHEMA_PROPERTY
    OKF_DIMENSION_WEIGHTS
    OKF_INGEST_AI_SCHEMA
    OKF_JUDGE_JSON_SCHEMA

    Functions

    buildAbstractPromptGuidelines
    buildBookOutlinePrompt
    buildBookOutlineSchema
    buildChapterFrontmatter
    buildDocumentPrompt
    buildMultilingualSchemaProperties
    buildOkfAiSchema
    buildOkfFrontmatter
    calculateTokenCost
    decomposeAndIngestMonograph
    extractBookOutline
    extractPdfPages
    extractPdfText
    extractSemanticContent
    parseOkfDocument
    resolveAiAdapter
    resolveStructuredRunner
    sanitizeOkfFrontmatter
    serializeOkfDocument
    sliceTextByChapters
    slugify
    writeOkfDocument

    References

    BradAgronomyProfile → AgroecologyTaxonomyProfile
    ingestMonograph → decomposeAndIngestMonograph