Adjust Chunk Delimiters
When processing large documents, you may want to control how the text is split into smaller chunks. By default, documents are split on newlines, but you can customize this behavior to better match your content structure. This example shows how to specify a custom delimiter for chunking documents.
import { MDocument } from "@mastra/rag";
const doc = MDocument.fromText("Your plain text content...");
const chunks = await doc.chunk({
separator: "\n",
});
View Example on GitHub