0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/packages/rag
dane-ai-mastra[bot] a5859ee2b9
chore: version packages (alpha) (#30430)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
History 2026-11-16 14:09:31 +01:00
..
src fix(rag): keep long JSON string content when chunking JSON documents (#30407) 2026-11-15 08:44:43 -08:00
.gitignore pinecone test 2024-11-19 17:43:42 -06:00
AGENTS.md chore: enforce AGENTS.md token limits (#15464) 2026-04-18 19:12:37 -07:00
CHANGELOG.md chore: version packages (alpha) (#30430) 2026-11-16 14:09:31 +01:00
docker-compose.yaml Chroma integration 2024-12-10 23:37:09 -08:00
lint-staged.config.js refactor(lint): replace ESLint with type-aware oxlint (#27476) 2026-10-18 10:38:35 -07:00
package.json chore: version packages (alpha) (#30430) 2026-11-16 14:09:31 +01:00
README.md chore(*): Update/unify/add READMEs (#22858) 2026-09-02 14:36:59 +02:00
tsconfig.build.json chore: fix go-to-definition using tsc declaration maps (#6089) 2025-07-30 15:41:00 -07:00
tsconfig.json chore: migrate package builds to tsdown (#19829) 2026-07-28 12:32:21 +02:00
tsdown.config.ts chore: migrate package builds to tsdown (#19829) 2026-07-28 12:32:21 +02:00
turbo.json chore: migrate package builds to tsdown (#19829) 2026-07-28 12:32:21 +02:00
vitest.config.ts fix: repair test failures surfaced by the full release-PR test run (#28116) 2026-10-22 13:15:26 +02:00

@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.