mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
|
History
|
||
|---|---|---|
| .. | ||
| src | ||
| .gitignore | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| docker-compose.yaml | ||
| lint-staged.config.js | ||
| package.json | ||
| README.md | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| tsdown.config.ts | ||
| turbo.json | ||
| vitest.config.ts | ||
@mastra/rag
@mastra/rag provides document chunking, reranking, and graph-based retrieval utilities for retrieval-augmented generation. Use it to prepare source material for embedding and select the most relevant context before an agent generates a response.
Installation
npm install @mastra/rag
Usage
Create a document and split it into chunks before embedding or indexing the content.
import { MDocument } from '@mastra/rag';
const document = MDocument.fromText(`
# Product guide
Mastra provides agents, workflows, memory, and retrieval tools.
`);
const chunks = await document.chunk({
strategy: 'recursive',
maxSize: 512,
overlap: 50,
});
Documentation
Changelog
See the package changelog for version history and release notes.
Support
We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.