Skip to content

loader component ​

The load_document component reads a file, URL, or directory into structured Document objects - plain text plus metadata - and optionally splits them into chunks. It is the ingestion step of a RAG pipeline: load, then feed the output into the vector_store or embedding component for indexing. It is a kdeps component from the components asset set: call it with a component: resource, no install step. Its call is the kdeps API's load_document tool, which runs the native loader executor. A workflow that uses loader: directly - primary or in a before:/after: step - is rejected.

It works in both modes: as a DAG step in workflow mode, and as the load_document built-in tool in agent mode.

component: load_documentPOST /tools/load_document/calltype?text / csvread filepdfextract page texthtmlfetch URL, extract textdirectory / notionevery file, one Document eachchunkSize > 0?recursive | token | markdowndocuments + counttext | csvpdfhtmldirectory | notion

Basic usage ​

yaml
# resources/load.yaml
actionId: load
name: Load Report
component:
  name: load_document       # from the components asset set; a components/load_document/ of your own wins
  with:
    type: pdf               # text (default), pdf, html, csv, directory, notion
    source: /data/quarterly-report.pdf
yaml
# resources/loadAndChunk.yaml
actionId: loadAndChunk
name: Load and Chunk for RAG
component:
  name: load_document
  with:
    type: text
    source: /data/handbook.txt
    chunkSize: 500          # split into chunks of 500 characters
    chunkOverlap: 50        # 50 characters shared by consecutive chunks
    chunkSplitter: recursive  # recursive (default), token, or markdown

Inputs ​

InputTypeRequiredDescription
sourcestringyesFile path, URL (for html), or directory path
typestringnotext (default), pdf, html, csv, directory, notion. Omitted types follow the file extension
columnsarraynoCSV only - column filter; empty loads all columns
passwordstringnoPDF only - decryption password for encrypted PDFs
chunkSizenumbernoWhen > 0, splits each loaded document into chunks of this size
chunkOverlapnumbernoCharacters of overlap between consecutive chunks
chunkSplitterstringnoSplitting strategy: recursive (default), token, or markdown

Loader types ​

typeReads
textPlain text file
pdfPDF file, page text extracted
htmlA URL - fetches and extracts readable text
csvCSV file, one Document per row (or per columns filter)
directoryEvery file in a directory, one Document per file

Output ​

json
{
  "documents": [
    { "content": "...", "metadata": { "source": "/data/handbook.txt", "chunk": 0 } }
  ],
  "count": 3
}

documents is directly usable as the documents: input to the vector_store component's add_documents operation - each content/metadata pair maps onto a VectorStoreDocument. The component returns the tool's body as a string, so read it with fromJSON.

Size limit ​

Every loader type reads its source fully into memory before returning - fine for a report or a handbook, but a workflow doing bulk ingestion (a large CSV, a directory of documents) risks an OS-level, no-core-dump SIGKILL once that content gets copied again downstream (chunkSize splitting, json.Marshal in the result, a vector_store step embedding it). Any single file over 256 MiB is rejected with a clear error instead - type: directory/notion skip an oversized file and keep loading the rest (a batch load should not abort over one large file); every other type fails that one load outright, the same way an explicit --file/stdin over its own 256 MiB default already does (see Input sources).

Raise or lower it with KDEPS_LOADER_MAX_BYTES (bytes; 0 disables the check):

bash
KDEPS_LOADER_MAX_BYTES=1073741824 kdeps run workflow.yaml  # 1 GiB, for a workflow that loads bulk data

RAG pipeline example ​

yaml
# resources/load.yaml
actionId: load
component:
  name: load_document
  with:
    type: pdf
    source: "{{ get('filePath') }}"
    chunkSize: 500
    chunkOverlap: 50
yaml
# resources/index.yaml
actionId: index
requires: [load]
component:
  name: vector_store
  with:
    operation: add_documents
    provider: qdrant
    url: http://localhost:6333
    collection: docs
    embedModel: text-embedding-3-small  # embedding model for the document contents
    documents: "{{ fromJSON(output('load')).documents }}"  # load_document's Document list

See also ​

Released under the Apache 2.0 License.