Skip to content

Loader resource ​

The loader: resource 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 vectorStore: or embedding: for indexing.

Where it runs ​

Both workflow mode and agent mode. In agent mode, the same loader is available as the load_document built-in tool.

Basic usage ​

yaml
# resources/load.yaml
actionId: load
name: Load Report
loader:
  type: pdf
  source: /data/quarterly-report.pdf
yaml
# resources/loadAndChunk.yaml
actionId: loadAndChunk
name: Load and Chunk for RAG
loader:
  type: text
  source: /data/handbook.txt
  chunkSize: 500
  chunkOverlap: 50
  chunkSplitter: recursive

Configuration options ​

OptionDescription
typeLoader to use: text (default), pdf, html, csv, directory
sourceFile path, URL (for html), or directory path (required)
columnsCSV only - optional column filter (empty = all columns)
passwordPDF only - decryption password for encrypted PDFs
chunkSizeWhen set (> 0), splits each loaded document into chunks of this size
chunkOverlapCharacters of overlap between consecutive chunks
chunkSplitterSplitting 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 a vectorStore: add_documents operation - each content/metadata pair maps onto a VectorStoreDocument.

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 vectorStore: 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
loader:
  type: pdf
  source: "{{ get('filePath') }}"
  chunkSize: 500
  chunkOverlap: 50
yaml
# resources/index.yaml
actionId: index
requires: [load]
vectorStore:
  operation: add_documents
  provider: qdrant
  url: http://localhost:6333
  collection: docs
  documents: "{{ get('load').documents }}"
  embedModel: text-embedding-3-small

See also ​

Released under the Apache 2.0 License.