Chunk Text
When working with large text documents, you need to break them down into smaller, manageable pieces for processing. The chunk method splits text content into segments that can be used for search, analysis, or retrieval. This example shows how to split plain text into chunks using default settings.
import { MDocument } from "@mastra/rag";
const doc = MDocument.fromText("Your plain text content...");
const chunks = await doc.chunk();
View Example on GitHub