@exulu/backend source. For option details, see Configuration.
Namespace import
SentenceChunker
SentenceChunker.create()
Static async factory. The constructor is private.CallableSentenceChunker — an object that is both callable and has class properties/methods.
Calling the chunker
SentenceChunk properties
chunk()
Chunk a single text string. Called internally when the chunker is invoked as a function.Properties
Aftercreate(), these are available on the instance:
RecursiveChunker
RecursiveChunker.create()
Static async factory. The constructor is private.Calling the chunker
RecursiveChunk properties
chunk()
Properties
RecursiveRules
Constructor
Array of level definitions. When omitted, the five built-in levels are used (paragraphs → sentences → punctuation → words → tokens).
whitespace and delimiters are mutually exclusive on a single level — passing both throws.
Properties and methods
MarkdownChunker
Enterprise Edition class. Instantiate directly:chunk()
The markdown text. Tables are converted to numbered-list format;
<page_break page=N> tags are tracked for page numbering.Target max tokens per chunk (effective budget is reduced by prefix and active header context tokens).
Optional string prepended to every chunk. Token count subtracted from the effective budget.
Prepend
<!-- Current page: N --> to each chunk.Full chunk content: optional page comment + header context (for non-current headers) + optional prefix + slice of the document.
Page number (1-based) in effect at the chunk boundary. Always 1 when no
<page_break> tags are present.convertTablesToText()
Converts markdown tables in a string to numbered-list format and returns the result. Called automatically bychunk().
ChunkerOperation and ChunkerResponse
These are the types that connect chunkers to ExuluContext.ChunkerOperation parameters
The fully hydrated item record. Includes
id, name, content, description, and all custom fields defined in the context schema.The token budget per chunk, derived from the embedder model’s
max_chunk_size as reported by LiteLLM. Pass this directly to the underlying chunker’s chunkSize option.S3-backed storage accessor. Use
utils.storage.read(s3key) to retrieve file content for file-backed contexts. For text-only items, this is not needed.ChunkerResponse
The original item, returned unchanged. Required.
The text content of this chunk. This is the text that will be embedded.
Zero-based position of this chunk. Must be contiguous (0, 1, 2, …) after filtering empty chunks — re-index with
.map((c, i) => ({ ...c, index: i })) after any filtering step.Arbitrary JSON-serializable metadata stored in the
metadata JSONB column of the chunks table. Common uses: { page: 3 }, { section: "Introduction" }, { source_url: "https://..." }. Null bytes in string values are stripped automatically.defaultChunker
ChunkerOperation used by ExuluContext when no chunker is configured. Concatenates item.name and item.content (falling back to item.description), runs SentenceChunker.create({ chunkSize: maxChunkSize }), and returns the results as a ChunkerResponse. Items with no usable text return { item, chunks: [] }.
Writing a custom chunker
ImplementChunkerOperation to handle file-backed, multi-source, or domain-specific chunking:
Next steps
Configuration
Every option for all three chunkers and chunk-size guidance.
ExuluContext
Assign a ChunkerOperation to a context.