@mastra/rag 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/docs/SKILL.md +8 -8
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-migrations-upgrade-to-v1-rag.md +44 -0
- package/dist/docs/references/reference-rag-chunk.md +5 -5
- package/dist/docs/references/{docs-rag-chunking-and-embedding.md → reference-rag-chunking-and-embedding.md} +17 -20
- package/dist/docs/references/reference-rag-database-config.md +3 -3
- package/dist/docs/references/{docs-rag-graph-rag.md → reference-rag-graph-rag-guide.md} +8 -8
- package/dist/docs/references/{docs-rag-overview.md → reference-rag-overview.md} +3 -3
- package/dist/docs/references/reference-rag-rerank.md +1 -1
- package/dist/docs/references/{docs-rag-retrieval.md → reference-rag-retrieval.md} +36 -19
- package/dist/docs/references/reference-tools-bedrock-kb-tool.md +117 -0
- package/dist/docs/references/reference-tools-graph-rag-tool.md +1 -1
- package/dist/docs/references/reference-tools-vector-query-tool.md +5 -5
- package/dist/docs/references/reference-vectors-oracledb.md +347 -0
- package/dist/document/types.d.ts.map +1 -1
- package/dist/index.cjs +6665 -7644
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6662 -7638
- package/dist/index.js.map +1 -1
- package/dist/tools/bedrock-knowledge-base.d.ts +29 -0
- package/dist/tools/bedrock-knowledge-base.d.ts.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/package.json +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @mastra/rag
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added Amazon Bedrock Knowledge Base tool (`createBedrockKBTool`) to @mastra/rag. Enables document retrieval from Bedrock Managed Knowledge Bases with agentic retrieval and automatic fallback. ([#19521](https://github.com/mastra-ai/mastra/pull/19521))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { createBedrockKBTool } from '@mastra/rag';
|
|
11
|
+
|
|
12
|
+
const tool = createBedrockKBTool({
|
|
13
|
+
knowledgeBaseId: 'YOUR_KB_ID',
|
|
14
|
+
region: 'us-west-2',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const results = await tool.execute({ queryText: 'What is RAG?' });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`e7109ee`](https://github.com/mastra-ai/mastra/commit/e7109ee6f731bacc79c885906f3c7dca8d8f013a), [`b8ce7ec`](https://github.com/mastra-ai/mastra/commit/b8ce7ec96e39343c6c2f36d12d68a9ad816c09f7), [`2e4624e`](https://github.com/mastra-ai/mastra/commit/2e4624edb6917e61249cb60ee377735e7af7e4a9), [`45a9147`](https://github.com/mastra-ai/mastra/commit/45a914741f578754d79d8b7de7b4e4f304d8e14a), [`a3a3624`](https://github.com/mastra-ai/mastra/commit/a3a3624f646b98e409424d8defccbd334da9e8b8), [`6246914`](https://github.com/mastra-ai/mastra/commit/62469146636911f3cbbe0880bd011c6a897a59a7), [`6445eba`](https://github.com/mastra-ai/mastra/commit/6445eba6020abac681aba1cc9289f446cb400cbe), [`86b7b77`](https://github.com/mastra-ai/mastra/commit/86b7b777980d30f66e1fd134a37d2af4c22e54cc), [`1c75e32`](https://github.com/mastra-ai/mastra/commit/1c75e32f7fc0b9fb6f548b4407feaec8a1440212), [`296dc9a`](https://github.com/mastra-ai/mastra/commit/296dc9af29f3616e786c7825ec32e0df92d754c5), [`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`3f73c07`](https://github.com/mastra-ai/mastra/commit/3f73c076727e8c36b4fff7a1b40290fb68957fa8), [`772c0c8`](https://github.com/mastra-ai/mastra/commit/772c0c897cec383258de2e6178147f8014767c7b), [`d7cf7fa`](https://github.com/mastra-ai/mastra/commit/d7cf7fafc1ae1b50bd8462dd0e6c671a8606db93), [`7c1ebb1`](https://github.com/mastra-ai/mastra/commit/7c1ebb15690c4b3f0eabb19077cf8af573311e57), [`0f9a448`](https://github.com/mastra-ai/mastra/commit/0f9a448502157e59f7b76f24360ad497168f5ef8), [`578bf2e`](https://github.com/mastra-ai/mastra/commit/578bf2e6a88e9d5b8bf502204e15a95dfbb679ae), [`c47165c`](https://github.com/mastra-ai/mastra/commit/c47165c983c87594c6952f1fd2fa51a90205034c), [`289f4ce`](https://github.com/mastra-ai/mastra/commit/289f4ce16e3293370440172132c52ee787cbc09f), [`df31eb0`](https://github.com/mastra-ai/mastra/commit/df31eb0c7087d782a0d9346e467f9a4af4b0eef6), [`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`4f16ff8`](https://github.com/mastra-ai/mastra/commit/4f16ff824bf2f9b0ddc93f210477c10c8a4fb1ab), [`b4c89b4`](https://github.com/mastra-ai/mastra/commit/b4c89b4371b0c86da57403ad1a3b3ef0681f3128), [`e6534fa`](https://github.com/mastra-ai/mastra/commit/e6534fab031216f6cb48c4c9907cbfdce9d60bc6), [`210cb7a`](https://github.com/mastra-ai/mastra/commit/210cb7a167998c7bbf72cb3b93e6eb0563330239), [`06b2d87`](https://github.com/mastra-ai/mastra/commit/06b2d87e63bcdd0ed59215c6789692b9b12de376), [`1c67d85`](https://github.com/mastra-ai/mastra/commit/1c67d85e9da8285662f4dbbf47e0378c3fee0747), [`ac01d63`](https://github.com/mastra-ai/mastra/commit/ac01d6355974aec73fdb8781449ed12bac582094), [`80a3324`](https://github.com/mastra-ai/mastra/commit/80a33245d3110204de6f56d61211523ffe338692), [`e44e8f3`](https://github.com/mastra-ai/mastra/commit/e44e8f370b66c339ddcaba946d33da6d3c3f06cd), [`d9d2881`](https://github.com/mastra-ai/mastra/commit/d9d2881ede6dd6c023d144215fc812062aed0890), [`a810a05`](https://github.com/mastra-ai/mastra/commit/a810a058f62ad407cfc1701e0be36ae91145d7cf), [`ba24be6`](https://github.com/mastra-ai/mastra/commit/ba24be662439c331ab23a600041f93803c89eca8), [`842b5fe`](https://github.com/mastra-ai/mastra/commit/842b5fe22b6a7fa811bd14e48eb9af523ac989f2), [`990611b`](https://github.com/mastra-ai/mastra/commit/990611ba76eb876d86c9c594371ae5f02f94b432), [`80bdf3a`](https://github.com/mastra-ai/mastra/commit/80bdf3ae16ade6ff63bde0cb16fa2df8ab7dd4dd), [`c967a5e`](https://github.com/mastra-ai/mastra/commit/c967a5eec150c5dc5418c4a4388982d1fb7ad27c), [`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b), [`9ba1247`](https://github.com/mastra-ai/mastra/commit/9ba12470c77f1c03642d720ce67e517e878f666e), [`fd96298`](https://github.com/mastra-ai/mastra/commit/fd96298a8367622f4ebfcaa97b5b6c1fbbd14564), [`66bbfb5`](https://github.com/mastra-ai/mastra/commit/66bbfb5f05b473d39f88c0e4a481ccac41634f3a), [`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b), [`f8da216`](https://github.com/mastra-ai/mastra/commit/f8da21633e7eb0e31c9ce0fc30567870d19416d3), [`4a09a9c`](https://github.com/mastra-ai/mastra/commit/4a09a9c0474ef643558fcb5f0edc542b82f1cab0), [`5f798b3`](https://github.com/mastra-ai/mastra/commit/5f798b3362e9bdf4d690f85245606e146eef60b9), [`6a84954`](https://github.com/mastra-ai/mastra/commit/6a84954a2667f85b6d59da652dab1bbff007ccb0), [`1e83a47`](https://github.com/mastra-ai/mastra/commit/1e83a4734ab61ba5926af6793e3569a78b72ed37), [`52d8ef0`](https://github.com/mastra-ai/mastra/commit/52d8ef03801f1deb7ee48532fc4190dd4a33916c), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`7fdcaa6`](https://github.com/mastra-ai/mastra/commit/7fdcaa66105d64290f9b14432a12ec99f39c4d3a), [`d6c56f9`](https://github.com/mastra-ai/mastra/commit/d6c56f951db3213330b98b0abafa9778c8770e58), [`e08e789`](https://github.com/mastra-ai/mastra/commit/e08e789c1bf4cd2fe46363f7a4728536ceccc9bd), [`bf936e2`](https://github.com/mastra-ai/mastra/commit/bf936e2c89b2ff0dad5695b873ddc009ba96d41e), [`7fb580a`](https://github.com/mastra-ai/mastra/commit/7fb580ac73fbcacf2ff00872a3395f73ae1b9fa5), [`ed5d606`](https://github.com/mastra-ai/mastra/commit/ed5d606739c5e3fbdfa9f272df7809aa5ab43b1d), [`f53d5bd`](https://github.com/mastra-ai/mastra/commit/f53d5bd4885b29e4ac29a428a6044088ea8d6aa3), [`32980a3`](https://github.com/mastra-ai/mastra/commit/32980a3e2413d0274ac244d32c37d910edc13f00), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`82e3365`](https://github.com/mastra-ai/mastra/commit/82e3365ef7c9bf7bee2e7a7029035ea262d68895), [`6104347`](https://github.com/mastra-ai/mastra/commit/61043473ba6bfd0a25156824e853e13165562e6c), [`35cc901`](https://github.com/mastra-ai/mastra/commit/35cc90102cf834a84827acaf9eee0b6d6d1e2a3b), [`a8b4cf0`](https://github.com/mastra-ai/mastra/commit/a8b4cf02823cffebc4751a53337dfacf097c1ae1), [`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`333785c`](https://github.com/mastra-ai/mastra/commit/333785c93cbb01e42c60167e995457c28897ddbf), [`bda2235`](https://github.com/mastra-ai/mastra/commit/bda22353ee28f2df0eaea555f7cae1549f979c0b), [`efd5c81`](https://github.com/mastra-ai/mastra/commit/efd5c81cc25fde3c2ddd86fc1178deb4ec176e19), [`1b482c2`](https://github.com/mastra-ai/mastra/commit/1b482c2d89244dd758c41e5f927a2b44041388d2), [`45bfb88`](https://github.com/mastra-ai/mastra/commit/45bfb88fd52f1dd3be20e2a38905777c96499c90), [`ff28284`](https://github.com/mastra-ai/mastra/commit/ff2828416f14daff9d956e6a352fdaa23c950979), [`4bcdfaf`](https://github.com/mastra-ai/mastra/commit/4bcdfaf0eac3199d7cb171b0a19a92c9c341eea4), [`e3b9307`](https://github.com/mastra-ai/mastra/commit/e3b9307098daefbfae2a52ae2ef51bc9fc701190), [`d6834c5`](https://github.com/mastra-ai/mastra/commit/d6834c5a7866b16734d23900163c2414ed70d791), [`f33264f`](https://github.com/mastra-ai/mastra/commit/f33264f517ae603279afd5c4251e2b40f6dd3618), [`689f2c4`](https://github.com/mastra-ai/mastra/commit/689f2c4b6c0835fe455702b01d21daa8abcd9331), [`fcd0667`](https://github.com/mastra-ai/mastra/commit/fcd0667a4e378be35c9a1b1eb19cce78fbfd7282), [`cfd0d9e`](https://github.com/mastra-ai/mastra/commit/cfd0d9ec77ec3c69dd96f79cdb579e03d79f22ce), [`acc3513`](https://github.com/mastra-ai/mastra/commit/acc3513b19f79bf0a7ec2998694580edca54086c), [`1670533`](https://github.com/mastra-ai/mastra/commit/1670533986f6bacf567746245348125e3a106448), [`a7eb4a1`](https://github.com/mastra-ai/mastra/commit/a7eb4a11450f6170274ed5141bffe821d4fdd5a6), [`0976933`](https://github.com/mastra-ai/mastra/commit/0976933142333ec78451feef265b68bcb45aa5e7), [`242b945`](https://github.com/mastra-ai/mastra/commit/242b94558777bfbdeb42cbfea84afff0b6ad0633), [`c52d346`](https://github.com/mastra-ai/mastra/commit/c52d3462ec831a5d95926ecd3d3373f5928ad2e5), [`af4636a`](https://github.com/mastra-ai/mastra/commit/af4636a74463275d71c1d13a38f7d2b738f128bf), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`2eabc09`](https://github.com/mastra-ai/mastra/commit/2eabc097d86d52fbd0123da36a7c874154cc384f), [`0023e79`](https://github.com/mastra-ai/mastra/commit/0023e7919431078280abd11c89d1edeae35fcc69), [`c2ad51e`](https://github.com/mastra-ai/mastra/commit/c2ad51e2467f901eecba8c9f4a45e22a50bd7c18), [`25ca73d`](https://github.com/mastra-ai/mastra/commit/25ca73d25dee7ce9f0ca72939e3a505c4db7257e), [`2f9ef3f`](https://github.com/mastra-ai/mastra/commit/2f9ef3f4ca06fc2dcdd5088c26b7f4da6a016791), [`e7eefcb`](https://github.com/mastra-ai/mastra/commit/e7eefcb162cda7c493e8c3bf43050ead0efbcb2c), [`fea5cae`](https://github.com/mastra-ai/mastra/commit/fea5caedc7e2cfea51784a15e015952692027abf), [`4d7aca2`](https://github.com/mastra-ai/mastra/commit/4d7aca2fe75f225c83d1502d63079568e6ec163f), [`e1cead1`](https://github.com/mastra-ai/mastra/commit/e1cead17b5f3653cf00d2f90cc19b113119c02ba), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`d9d93b2`](https://github.com/mastra-ai/mastra/commit/d9d93b25e4a65ad5fa153fa35be7ed149c8d587f), [`c4ec889`](https://github.com/mastra-ai/mastra/commit/c4ec889561c0264c43f66d04d587bee4ce35e792), [`4b59f78`](https://github.com/mastra-ai/mastra/commit/4b59f786cbc9a7d1ef07a07517dbd4b96865e99d), [`eeae63e`](https://github.com/mastra-ai/mastra/commit/eeae63e7fbe8e1f237adc69bca6e2ac13c5ca907), [`3dc97ea`](https://github.com/mastra-ai/mastra/commit/3dc97ea415fad353b48a13095fad1835933cc12a), [`94e7ae9`](https://github.com/mastra-ai/mastra/commit/94e7ae970b37c888cd1244ef013292639a2fe6d1), [`e6a2860`](https://github.com/mastra-ai/mastra/commit/e6a2860649cc51f87d32d78b766ae2126446ba07), [`7010c5d`](https://github.com/mastra-ai/mastra/commit/7010c5d15728bf9c5dfe4fb6b1bf80ce23bf143a), [`bab06b1`](https://github.com/mastra-ai/mastra/commit/bab06b18923873a584bdfc71a6b4ec7fb4727fb7), [`3d01cd3`](https://github.com/mastra-ai/mastra/commit/3d01cd387321b6f9c5cac31d487c84bf51b19c78), [`7bf3086`](https://github.com/mastra-ai/mastra/commit/7bf308663f0115ca74ad20554ade740f06640859), [`4c186a0`](https://github.com/mastra-ai/mastra/commit/4c186a017275f45e6ed4c09de0f89550e2d09e8c), [`b0fa077`](https://github.com/mastra-ai/mastra/commit/b0fa077bcbc9b08551846fe372a0d3d15b71ed72), [`0282e16`](https://github.com/mastra-ai/mastra/commit/0282e16115538c8e9b248b90f0748eb01cb5dc98), [`a8dd139`](https://github.com/mastra-ai/mastra/commit/a8dd1391a9fe9a6632c25809ef236980afa9a020), [`6a667b4`](https://github.com/mastra-ai/mastra/commit/6a667b4b7cd6a93fe41fcdd357b08c5a8c09b9ab), [`9be8878`](https://github.com/mastra-ai/mastra/commit/9be8878dcf0388e84fc4873e0eec27bd49b881a4), [`e5786be`](https://github.com/mastra-ai/mastra/commit/e5786be02bb903073082bd9d6da880ebaacc343f), [`2440e09`](https://github.com/mastra-ai/mastra/commit/2440e096ea6c2def1ccc1eb2d0f3f5b88c4af940), [`2093fbd`](https://github.com/mastra-ai/mastra/commit/2093fbd53bb744bae19ec89f6d73db9a66fbe8a7), [`a59049b`](https://github.com/mastra-ai/mastra/commit/a59049b1652a13efff66ac826326b5ed9a550342), [`7bd85ea`](https://github.com/mastra-ai/mastra/commit/7bd85ea7588b71c25ce9f4019c88f8539be5dcbc), [`83fa004`](https://github.com/mastra-ai/mastra/commit/83fa0044bfda8b703a83883dbd8bef204844d13f), [`a463cdf`](https://github.com/mastra-ai/mastra/commit/a463cdf1c95c3059e70f0bff27959e8558bb899d), [`e7a5da4`](https://github.com/mastra-ai/mastra/commit/e7a5da4ef8e4dd452d2f232961b4e682a85ffe43), [`7b4393d`](https://github.com/mastra-ai/mastra/commit/7b4393d557411fdcf07b0e30e5acaf7cc85154ae), [`0ea6b80`](https://github.com/mastra-ai/mastra/commit/0ea6b8001408ce02b56e8be0536b0fd8cbaf8ad2)]:
|
|
23
|
+
- @mastra/core@1.58.0
|
|
24
|
+
|
|
25
|
+
## 2.5.0-alpha.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- Added Amazon Bedrock Knowledge Base tool (`createBedrockKBTool`) to @mastra/rag. Enables document retrieval from Bedrock Managed Knowledge Bases with agentic retrieval and automatic fallback. ([#19521](https://github.com/mastra-ai/mastra/pull/19521))
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { createBedrockKBTool } from '@mastra/rag';
|
|
33
|
+
|
|
34
|
+
const tool = createBedrockKBTool({
|
|
35
|
+
knowledgeBaseId: 'YOUR_KB_ID',
|
|
36
|
+
region: 'us-west-2',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const results = await tool.execute({ queryText: 'What is RAG?' });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [[`b4c89b4`](https://github.com/mastra-ai/mastra/commit/b4c89b4371b0c86da57403ad1a3b3ef0681f3128), [`e44e8f3`](https://github.com/mastra-ai/mastra/commit/e44e8f370b66c339ddcaba946d33da6d3c3f06cd), [`c967a5e`](https://github.com/mastra-ai/mastra/commit/c967a5eec150c5dc5418c4a4388982d1fb7ad27c), [`f53d5bd`](https://github.com/mastra-ai/mastra/commit/f53d5bd4885b29e4ac29a428a6044088ea8d6aa3), [`bda2235`](https://github.com/mastra-ai/mastra/commit/bda22353ee28f2df0eaea555f7cae1549f979c0b), [`a7eb4a1`](https://github.com/mastra-ai/mastra/commit/a7eb4a11450f6170274ed5141bffe821d4fdd5a6), [`2f9ef3f`](https://github.com/mastra-ai/mastra/commit/2f9ef3f4ca06fc2dcdd5088c26b7f4da6a016791), [`e7eefcb`](https://github.com/mastra-ai/mastra/commit/e7eefcb162cda7c493e8c3bf43050ead0efbcb2c), [`4d7aca2`](https://github.com/mastra-ai/mastra/commit/4d7aca2fe75f225c83d1502d63079568e6ec163f), [`c4ec889`](https://github.com/mastra-ai/mastra/commit/c4ec889561c0264c43f66d04d587bee4ce35e792), [`9be8878`](https://github.com/mastra-ai/mastra/commit/9be8878dcf0388e84fc4873e0eec27bd49b881a4)]:
|
|
45
|
+
- @mastra/core@1.58.0-alpha.2
|
|
46
|
+
|
|
3
47
|
## 2.4.2
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-rag
|
|
|
3
3
|
description: Documentation for @mastra/rag. Use when working with @mastra/rag APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/rag"
|
|
6
|
-
version: "2.
|
|
6
|
+
version: "2.5.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -14,25 +14,25 @@ Use this skill whenever you are working with @mastra/rag to obtain the domain-sp
|
|
|
14
14
|
|
|
15
15
|
Read the individual reference documents for detailed explanations and code examples.
|
|
16
16
|
|
|
17
|
-
### Docs
|
|
18
|
-
|
|
19
|
-
- [Chunking and embedding documents](references/docs-rag-chunking-and-embedding.md) - Guide on chunking and embedding documents in Mastra for efficient processing and retrieval.
|
|
20
|
-
- [GraphRAG](references/docs-rag-graph-rag.md) - Guide on graph-based retrieval in Mastra's RAG systems for documents with complex relationships.
|
|
21
|
-
- [RAG (Retrieval-Augmented Generation) in Mastra](references/docs-rag-overview.md) - Overview of Retrieval-Augmented Generation (RAG) in Mastra, detailing its capabilities for enhancing LLM outputs with relevant context.
|
|
22
|
-
- [Retrieval, semantic search, reranking](references/docs-rag-retrieval.md) - Guide on retrieval processes in Mastra's RAG systems, including semantic search, filtering, and re-ranking.
|
|
23
|
-
|
|
24
17
|
### Reference
|
|
25
18
|
|
|
19
|
+
- [RAG](references/reference-migrations-upgrade-to-v1-rag.md) - Migrate RAG-related breaking changes when upgrading to v1.
|
|
26
20
|
- [Reference: .chunk()](references/reference-rag-chunk.md) - Documentation for the chunk function in Mastra, which splits documents into smaller segments using various strategies.
|
|
21
|
+
- [Chunking and embedding documents](references/reference-rag-chunking-and-embedding.md) - Guide on chunking and embedding documents in Mastra for efficient processing and retrieval.
|
|
27
22
|
- [Reference: DatabaseConfig](references/reference-rag-database-config.md) - API reference for database-specific configuration types used with vector query tools in Mastra RAG systems.
|
|
28
23
|
- [Reference: MDocument](references/reference-rag-document.md) - Documentation for the MDocument class in Mastra, which handles document processing and chunking.
|
|
29
24
|
- [Reference: ExtractParams](references/reference-rag-extract-params.md) - Documentation for metadata extraction configuration in Mastra.
|
|
30
25
|
- [Reference: GraphRAG](references/reference-rag-graph-rag.md) - Documentation for the GraphRAG class in Mastra, which implements a graph-based approach to retrieval augmented generation.
|
|
26
|
+
- [GraphRAG](references/reference-rag-graph-rag-guide.md) - Guide on graph-based retrieval in Mastra's RAG systems for documents with complex relationships.
|
|
27
|
+
- [RAG (Retrieval-Augmented Generation) in Mastra](references/reference-rag-overview.md) - Overview of Retrieval-Augmented Generation (RAG) in Mastra, detailing its capabilities for enhancing LLM outputs with relevant context.
|
|
31
28
|
- [Reference: rerank()](references/reference-rag-rerank.md) - Documentation for the rerank function in Mastra, which provides advanced reranking capabilities for vector search results.
|
|
32
29
|
- [Reference: rerankWithScorer()](references/reference-rag-rerankWithScorer.md) - Documentation for the rerank function in Mastra, which provides advanced reranking capabilities for vector search results.
|
|
30
|
+
- [Retrieval, semantic search, reranking](references/reference-rag-retrieval.md) - Guide on retrieval processes in Mastra's RAG systems, including semantic search, filtering, and re-ranking.
|
|
31
|
+
- [Reference: createBedrockKBTool()](references/reference-tools-bedrock-kb-tool.md) - Documentation for the Bedrock Knowledge Base Tool in Mastra, which retrieves documents from Amazon Bedrock Knowledge Bases with agentic retrieval support.
|
|
33
32
|
- [Reference: createDocumentChunkerTool()](references/reference-tools-document-chunker-tool.md) - Documentation for the Document Chunker Tool in Mastra, which splits documents into smaller chunks for efficient processing and retrieval.
|
|
34
33
|
- [Reference: createGraphRAGTool()](references/reference-tools-graph-rag-tool.md) - Documentation for the GraphRAG Tool in Mastra, which enhances RAG by building a graph of semantic relationships between documents.
|
|
35
34
|
- [Reference: createVectorQueryTool()](references/reference-tools-vector-query-tool.md) - Documentation for the Vector Query Tool in Mastra, which facilitates semantic search over vector stores with filtering and reranking capabilities.
|
|
35
|
+
- [Reference: OracleDB vector store](references/reference-vectors-oracledb.md) - Documentation for the Oracle Database vector provider in Mastra.
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# RAG
|
|
4
|
+
|
|
5
|
+
The RAG package has renamed chunking parameters and narrowed their types.
|
|
6
|
+
|
|
7
|
+
## Changed
|
|
8
|
+
|
|
9
|
+
### `keepSeparator` to `separatorPosition`
|
|
10
|
+
|
|
11
|
+
The `keepSeparator` parameter has been renamed to `separatorPosition` with a simplified type. The old parameter had a confusing `boolean | 'start' | 'end'` type where `true` was secretly an alias for `'start'`. The new parameter uses explicit `'start' | 'end'` values, and omitting the parameter discards the separator.
|
|
12
|
+
|
|
13
|
+
To migrate, replace `keepSeparator` with `separatorPosition` using the mapping below:
|
|
14
|
+
|
|
15
|
+
| Old value | New value |
|
|
16
|
+
| ------------------------ | ---------------------------- |
|
|
17
|
+
| `keepSeparator: true` | `separatorPosition: 'start'` |
|
|
18
|
+
| `keepSeparator: 'start'` | `separatorPosition: 'start'` |
|
|
19
|
+
| `keepSeparator: 'end'` | `separatorPosition: 'end'` |
|
|
20
|
+
| `keepSeparator: false` | Remove the parameter |
|
|
21
|
+
| Parameter omitted | No change needed |
|
|
22
|
+
|
|
23
|
+
```diff
|
|
24
|
+
await doc.chunk({
|
|
25
|
+
strategy: 'character',
|
|
26
|
+
separator: '.',
|
|
27
|
+
- keepSeparator: true,
|
|
28
|
+
+ separatorPosition: 'start',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await doc.chunk({
|
|
32
|
+
strategy: 'character',
|
|
33
|
+
separator: '.',
|
|
34
|
+
- keepSeparator: 'end',
|
|
35
|
+
+ separatorPosition: 'end',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await doc.chunk({
|
|
39
|
+
strategy: 'character',
|
|
40
|
+
separator: '.',
|
|
41
|
+
- keepSeparator: false,
|
|
42
|
+
+ // Parameter removed - separator is discarded by default
|
|
43
|
+
});
|
|
44
|
+
```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# .chunk()
|
|
4
4
|
|
|
5
|
-
The `.chunk()` function splits documents into smaller segments using
|
|
5
|
+
The `.chunk()` function splits documents into smaller segments using strategies and options.
|
|
6
6
|
|
|
7
7
|
## Example
|
|
8
8
|
|
|
@@ -39,11 +39,11 @@ const chunksWithMetadata = await doc.chunk({
|
|
|
39
39
|
|
|
40
40
|
## Parameters
|
|
41
41
|
|
|
42
|
-
The following parameters are available for all chunking strategies.
|
|
42
|
+
The following parameters are available for all chunking strategies. Each strategy will only utilize a subset of these parameters relevant to its specific use case.
|
|
43
43
|
|
|
44
44
|
**strategy** (`'recursive' | 'character' | 'token' | 'markdown' | 'semantic-markdown' | 'html' | 'json' | 'latex' | 'sentence'`): The chunking strategy to use. If not specified, defaults based on document type. Depending on the chunking strategy, there are additional optionals. Defaults: .md files → 'markdown', .html/.htm → 'html', .json → 'json', .tex → 'latex', others → 'recursive'
|
|
45
45
|
|
|
46
|
-
**maxSize** (`number`): Maximum size of each chunk.
|
|
46
|
+
**maxSize** (`number`): Maximum size of each chunk. Some strategy configurations (markdown with headers, HTML with headers) ignore this parameter. (Default: `4000`)
|
|
47
47
|
|
|
48
48
|
**overlap** (`number`): Number of characters/tokens that overlap between chunks. (Default: `50`)
|
|
49
49
|
|
|
@@ -162,7 +162,7 @@ The options documented below are passed directly at the top level of the configu
|
|
|
162
162
|
|
|
163
163
|
**returnEachLine** (`boolean`): Whether to return each line as a separate chunk
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
When using the HTML strategy, all general options are ignored. Use `headers` for header-based splitting or `sections` for section-based splitting. If used together, `sections` will be ignored.
|
|
166
166
|
|
|
167
167
|
### Markdown
|
|
168
168
|
|
|
@@ -172,7 +172,7 @@ The options documented below are passed directly at the top level of the configu
|
|
|
172
172
|
|
|
173
173
|
**returnEachLine** (`boolean`): Whether to return each line as a separate chunk
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
When using the `headers` option, the markdown strategy ignores all general options and content is split based on the markdown header structure. To use size-based chunking with markdown, omit the `headers` parameter.
|
|
176
176
|
|
|
177
177
|
### Semantic Markdown
|
|
178
178
|
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# Chunking and embedding documents
|
|
4
4
|
|
|
5
|
-
Before processing, create a MDocument instance from your content. You can initialize it from
|
|
5
|
+
Before processing, create a MDocument instance from your content. You can initialize it from different formats:
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
|
|
8
|
+
import { MDocument } from '@mastra/rag'
|
|
9
|
+
|
|
10
|
+
const doc = MDocument.fromText('Your plain text content...')
|
|
9
11
|
const docFromHTML = MDocument.fromHTML('<html>Your HTML content...</html>')
|
|
10
12
|
const docFromMarkdown = MDocument.fromMarkdown('# Your Markdown content...')
|
|
11
13
|
const docFromJSON = MDocument.fromJSON(`{ "key": "value" }`)
|
|
@@ -59,7 +61,7 @@ For markdown documents where preserving the semantic relationships between secti
|
|
|
59
61
|
const chunks = await doc.chunk({
|
|
60
62
|
strategy: 'semantic-markdown',
|
|
61
63
|
joinThreshold: 500,
|
|
62
|
-
modelName: 'gpt-
|
|
64
|
+
modelName: 'gpt-5',
|
|
63
65
|
})
|
|
64
66
|
```
|
|
65
67
|
|
|
@@ -129,51 +131,46 @@ const { embeddings } = await embedMany({
|
|
|
129
131
|
|
|
130
132
|
## Example: Complete pipeline
|
|
131
133
|
|
|
132
|
-
Here's an example showing document processing
|
|
134
|
+
Here's an example showing document processing, embedding generation, and vector storage:
|
|
133
135
|
|
|
134
136
|
```ts
|
|
135
|
-
import {
|
|
136
|
-
|
|
137
|
+
import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
|
|
138
|
+
import { PgVector } from '@mastra/pg'
|
|
137
139
|
import { MDocument } from '@mastra/rag'
|
|
140
|
+
import { embedMany } from 'ai'
|
|
138
141
|
|
|
139
|
-
// Initialize document
|
|
140
142
|
const doc = MDocument.fromText(`
|
|
141
143
|
Climate change poses significant challenges to global agriculture.
|
|
142
144
|
Rising temperatures and changing precipitation patterns affect crop yields.
|
|
143
145
|
`)
|
|
144
146
|
|
|
145
|
-
// Create chunks
|
|
146
147
|
const chunks = await doc.chunk({
|
|
147
148
|
strategy: 'recursive',
|
|
148
149
|
maxSize: 256,
|
|
149
150
|
overlap: 50,
|
|
150
151
|
})
|
|
151
152
|
|
|
152
|
-
// Generate embeddings with OpenAI
|
|
153
|
-
import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
|
|
154
|
-
|
|
155
153
|
const { embeddings } = await embedMany({
|
|
156
154
|
model: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
|
|
157
155
|
values: chunks.map(chunk => chunk.text),
|
|
158
156
|
})
|
|
159
157
|
|
|
160
|
-
|
|
158
|
+
const vectorStore = new PgVector({
|
|
159
|
+
id: 'pg-vector',
|
|
160
|
+
connectionString: process.env.POSTGRES_CONNECTION_STRING,
|
|
161
|
+
})
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
values: chunks.map(chunk => chunk.text),
|
|
163
|
+
await vectorStore.createIndex({
|
|
164
|
+
indexName: 'embeddings',
|
|
165
|
+
dimension: 1536,
|
|
166
166
|
})
|
|
167
167
|
|
|
168
|
-
// Store embeddings in your vector database
|
|
169
168
|
await vectorStore.upsert({
|
|
170
169
|
indexName: 'embeddings',
|
|
171
170
|
vectors: embeddings,
|
|
172
171
|
})
|
|
173
172
|
```
|
|
174
173
|
|
|
175
|
-
##
|
|
176
|
-
|
|
177
174
|
For more examples of different chunking strategies and embedding configurations, see:
|
|
178
175
|
|
|
179
176
|
- [Chunk Reference](https://mastra.ai/reference/rag/chunk)
|
|
@@ -181,5 +178,5 @@ For more examples of different chunking strategies and embedding configurations,
|
|
|
181
178
|
|
|
182
179
|
For more details on vector databases and embeddings, see:
|
|
183
180
|
|
|
184
|
-
- [Vector Databases](https://mastra.ai/
|
|
181
|
+
- [Vector Databases](https://mastra.ai/reference/rag/vector-databases)
|
|
185
182
|
- [Embedding API Reference](https://mastra.ai/reference/rag/embeddings)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# DatabaseConfig
|
|
4
4
|
|
|
5
|
-
The `DatabaseConfig` type allows you to specify database-specific configurations when using vector query tools. These configurations enable you to
|
|
5
|
+
The `DatabaseConfig` type allows you to specify database-specific configurations when using vector query tools. These configurations enable you to use features and optimizations offered by different vector stores.
|
|
6
6
|
|
|
7
7
|
## Type definition
|
|
8
8
|
|
|
@@ -252,7 +252,7 @@ const vectorTool = createVectorQueryTool({
|
|
|
252
252
|
1. **Environment Configuration**: Use different namespaces or configurations for different environments
|
|
253
253
|
2. **Performance Tuning**: Start with default values and adjust based on your specific needs
|
|
254
254
|
3. **Quality Filtering**: Use minScore to filter out low-quality results
|
|
255
|
-
4. **Runtime Flexibility**: Override configurations at runtime for
|
|
255
|
+
4. **Runtime Flexibility**: Override configurations at runtime for runtime-defined scenarios
|
|
256
256
|
5. **Documentation**: Document your specific configuration choices for team members
|
|
257
257
|
|
|
258
258
|
## Migration guide
|
|
@@ -275,5 +275,5 @@ const vectorTool = createVectorQueryTool({
|
|
|
275
275
|
## Related
|
|
276
276
|
|
|
277
277
|
- [createVectorQueryTool()](https://mastra.ai/reference/tools/vector-query-tool)
|
|
278
|
-
- [Hybrid Vector Search](https://mastra.ai/
|
|
278
|
+
- [Hybrid Vector Search](https://mastra.ai/reference/rag/retrieval)
|
|
279
279
|
- [Metadata Filters](https://mastra.ai/reference/rag/metadata-filters)
|
|
@@ -14,7 +14,7 @@ GraphRAG is particularly effective when:
|
|
|
14
14
|
- Understanding connections between concepts is important
|
|
15
15
|
- Simple vector similarity misses important contextual relationships
|
|
16
16
|
|
|
17
|
-
For straightforward semantic search without relationship traversal, use [standard retrieval methods](https://mastra.ai/
|
|
17
|
+
For straightforward semantic search without relationship traversal, use [standard retrieval methods](https://mastra.ai/reference/rag/retrieval).
|
|
18
18
|
|
|
19
19
|
## How GraphRAG works
|
|
20
20
|
|
|
@@ -49,7 +49,7 @@ const graphQueryTool = createGraphRAGTool({
|
|
|
49
49
|
|
|
50
50
|
The `graphOptions` parameter controls how the knowledge graph is built and traversed:
|
|
51
51
|
|
|
52
|
-
- `threshold`: Similarity threshold (0-1) for determining which chunks are related. Higher values create sparser graphs with stronger connections
|
|
52
|
+
- `threshold`: Similarity threshold (0-1) for determining which chunks are related. Higher values create sparser graphs with stronger connections. Lower values create denser graphs with more potential relationships.
|
|
53
53
|
- `dimension`: Vector embedding dimension. Must match the embedding model's output dimension (e.g., 1536 for OpenAI's text-embedding-3-small).
|
|
54
54
|
|
|
55
55
|
```ts
|
|
@@ -77,7 +77,7 @@ const ragAgent = new Agent({
|
|
|
77
77
|
instructions: `You are a helpful assistant that answers questions based on the provided context.
|
|
78
78
|
When answering questions, use the graph query tool to find relevant information and relationships.
|
|
79
79
|
Base your answers on the context provided by the tool, and clearly state if the context doesn't contain enough information.`,
|
|
80
|
-
model: 'openai/gpt-5.
|
|
80
|
+
model: 'openai/gpt-5.6-sol',
|
|
81
81
|
tools: {
|
|
82
82
|
graphQueryTool,
|
|
83
83
|
},
|
|
@@ -138,15 +138,15 @@ The agent uses the graph query tool to:
|
|
|
138
138
|
2. Find semantically similar chunks in the vector store
|
|
139
139
|
3. Build a knowledge graph from related chunks
|
|
140
140
|
4. Traverse the graph to find connected information
|
|
141
|
-
5. Return
|
|
141
|
+
5. Return complete context for generating the response
|
|
142
142
|
|
|
143
143
|
## Choosing the right threshold
|
|
144
144
|
|
|
145
|
-
The threshold parameter
|
|
145
|
+
The threshold parameter substantially impacts retrieval quality:
|
|
146
146
|
|
|
147
|
-
- **High threshold (0.8-0.9)**: Strict connections
|
|
147
|
+
- **High threshold (0.8-0.9)**: Strict connections and fewer relationships, plus more precise but potentially incomplete results
|
|
148
148
|
- **Medium threshold (0.6-0.8)**: Balanced approach, good for most use cases
|
|
149
|
-
- **Low threshold (0.4-0.6)**: More connections
|
|
149
|
+
- **Low threshold (0.4-0.6)**: More connections and broader context, plus risk of including less relevant information
|
|
150
150
|
|
|
151
151
|
Start with 0.7 and adjust based on your specific use case:
|
|
152
152
|
|
|
@@ -199,7 +199,7 @@ const agent = new Agent({
|
|
|
199
199
|
name: 'RAG Agent',
|
|
200
200
|
instructions: `Use vector search for simple fact-finding queries.
|
|
201
201
|
Use graph search when you need to understand relationships or find connected information.`,
|
|
202
|
-
model: 'openai/gpt-5.
|
|
202
|
+
model: 'openai/gpt-5.6-sol',
|
|
203
203
|
tools: {
|
|
204
204
|
vectorQueryTool,
|
|
205
205
|
graphQueryTool,
|
|
@@ -59,15 +59,15 @@ const results = await pgVector.query({
|
|
|
59
59
|
console.log('Similar chunks:', results)
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
This example shows the essentials
|
|
62
|
+
This example shows the essentials. Initialize a document and create chunks, then generate and store embeddings before querying for similar content.
|
|
63
63
|
|
|
64
64
|
## Document processing
|
|
65
65
|
|
|
66
|
-
The basic building block of RAG is document processing. Documents can be chunked using
|
|
66
|
+
The basic building block of RAG is document processing. Documents can be chunked using strategies (recursive, sliding window, etc.) and enriched with metadata. See the [chunking and embedding doc](https://mastra.ai/reference/rag/chunking-and-embedding).
|
|
67
67
|
|
|
68
68
|
## Vector storage
|
|
69
69
|
|
|
70
|
-
Mastra supports multiple vector stores for embedding persistence and similarity search, including pgvector, Pinecone, Qdrant, and MongoDB. See the [vector database doc](https://mastra.ai/
|
|
70
|
+
Mastra supports multiple vector stores for embedding persistence and similarity search, including pgvector, OracleDB, Pinecone, Qdrant, and MongoDB. See the [vector database doc](https://mastra.ai/reference/rag/vector-databases).
|
|
71
71
|
|
|
72
72
|
## More resources
|
|
73
73
|
|
|
@@ -18,7 +18,7 @@ function rerank(
|
|
|
18
18
|
```typescript
|
|
19
19
|
import { rerank } from '@mastra/rag'
|
|
20
20
|
|
|
21
|
-
const model = 'openai/gpt-5.
|
|
21
|
+
const model = 'openai/gpt-5.6-sol'
|
|
22
22
|
|
|
23
23
|
const rerankedResults = await rerank(vectorSearchResults, 'How do I deploy to production?', model, {
|
|
24
24
|
weights: {
|
|
@@ -160,15 +160,15 @@ When creating the tool, pay special attention to the tool's name and description
|
|
|
160
160
|
|
|
161
161
|
This is particularly useful when:
|
|
162
162
|
|
|
163
|
-
- Your agent needs to
|
|
163
|
+
- Your agent needs to decide at runtime what information to retrieve
|
|
164
164
|
- The retrieval process requires complex decision-making
|
|
165
165
|
- You want the agent to combine multiple retrieval strategies based on context
|
|
166
166
|
|
|
167
167
|
#### Database-Specific Configurations
|
|
168
168
|
|
|
169
|
-
The Vector Query Tool supports database-specific configurations that enable you to
|
|
169
|
+
The Vector Query Tool supports database-specific configurations that enable you to use unique features and optimizations of different vector stores.
|
|
170
170
|
|
|
171
|
-
> **Note:** These configurations are for **query-time options** like namespaces, performance tuning, and filtering
|
|
171
|
+
> **Note:** These configurations are for **query-time options** like namespaces, performance tuning, and filtering, not for database connection setup.
|
|
172
172
|
>
|
|
173
173
|
> Connection credentials (URLs, auth tokens) are configured when you instantiate the vector store class (e.g., `new LibSQLVector({ url: '...' })`).
|
|
174
174
|
|
|
@@ -235,7 +235,7 @@ const lanceQueryTool = createVectorQueryTool({
|
|
|
235
235
|
- **pgVector optimization**: Control search accuracy and speed with ef/probes parameters
|
|
236
236
|
- **Quality filtering**: Set minimum similarity thresholds to improve result relevance
|
|
237
237
|
- **LanceDB tables**: Separate data into tables for better organization and performance
|
|
238
|
-
- **Runtime flexibility**: Override configurations
|
|
238
|
+
- **Runtime flexibility**: Override configurations at runtime based on context
|
|
239
239
|
|
|
240
240
|
**Common Use Cases:**
|
|
241
241
|
|
|
@@ -274,7 +274,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
274
274
|
export const ragAgent = new Agent({
|
|
275
275
|
id: 'rag-agent',
|
|
276
276
|
name: 'RAG Agent',
|
|
277
|
-
model: 'openai/gpt-5.
|
|
277
|
+
model: 'openai/gpt-5.6-sol',
|
|
278
278
|
instructions: `
|
|
279
279
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
280
280
|
${PGVECTOR_PROMPT}
|
|
@@ -291,7 +291,7 @@ import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
|
291
291
|
export const ragAgent = new Agent({
|
|
292
292
|
id: 'rag-agent',
|
|
293
293
|
name: 'RAG Agent',
|
|
294
|
-
model: 'openai/gpt-5.
|
|
294
|
+
model: 'openai/gpt-5.6-sol',
|
|
295
295
|
instructions: `
|
|
296
296
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
297
297
|
${PINECONE_PROMPT}
|
|
@@ -308,7 +308,7 @@ import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
|
308
308
|
export const ragAgent = new Agent({
|
|
309
309
|
id: 'rag-agent',
|
|
310
310
|
name: 'RAG Agent',
|
|
311
|
-
model: 'openai/gpt-5.
|
|
311
|
+
model: 'openai/gpt-5.6-sol',
|
|
312
312
|
instructions: `
|
|
313
313
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
314
314
|
${QDRANT_PROMPT}
|
|
@@ -325,7 +325,7 @@ import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
|
325
325
|
export const ragAgent = new Agent({
|
|
326
326
|
id: 'rag-agent',
|
|
327
327
|
name: 'RAG Agent',
|
|
328
|
-
model: 'openai/gpt-5.
|
|
328
|
+
model: 'openai/gpt-5.6-sol',
|
|
329
329
|
instructions: `
|
|
330
330
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
331
331
|
${CHROMA_PROMPT}
|
|
@@ -342,7 +342,7 @@ import { ASTRA_PROMPT } from '@mastra/astra'
|
|
|
342
342
|
export const ragAgent = new Agent({
|
|
343
343
|
id: 'rag-agent',
|
|
344
344
|
name: 'RAG Agent',
|
|
345
|
-
model: 'openai/gpt-5.
|
|
345
|
+
model: 'openai/gpt-5.6-sol',
|
|
346
346
|
instructions: `
|
|
347
347
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
348
348
|
${ASTRA_PROMPT}
|
|
@@ -359,7 +359,7 @@ import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
|
359
359
|
export const ragAgent = new Agent({
|
|
360
360
|
id: 'rag-agent',
|
|
361
361
|
name: 'RAG Agent',
|
|
362
|
-
model: 'openai/gpt-5.
|
|
362
|
+
model: 'openai/gpt-5.6-sol',
|
|
363
363
|
instructions: `
|
|
364
364
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
365
365
|
${LIBSQL_PROMPT}
|
|
@@ -376,7 +376,7 @@ import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
|
376
376
|
export const ragAgent = new Agent({
|
|
377
377
|
id: 'rag-agent',
|
|
378
378
|
name: 'RAG Agent',
|
|
379
|
-
model: 'openai/gpt-5.
|
|
379
|
+
model: 'openai/gpt-5.6-sol',
|
|
380
380
|
instructions: `
|
|
381
381
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
382
382
|
${UPSTASH_PROMPT}
|
|
@@ -393,7 +393,7 @@ import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
|
393
393
|
export const ragAgent = new Agent({
|
|
394
394
|
id: 'rag-agent',
|
|
395
395
|
name: 'RAG Agent',
|
|
396
|
-
model: 'openai/gpt-5.
|
|
396
|
+
model: 'openai/gpt-5.6-sol',
|
|
397
397
|
instructions: `
|
|
398
398
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
399
399
|
${VECTORIZE_PROMPT}
|
|
@@ -410,7 +410,7 @@ import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
|
410
410
|
export const ragAgent = new Agent({
|
|
411
411
|
id: 'rag-agent',
|
|
412
412
|
name: 'RAG Agent',
|
|
413
|
-
model: 'openai/gpt-5.
|
|
413
|
+
model: 'openai/gpt-5.6-sol',
|
|
414
414
|
instructions: `
|
|
415
415
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
416
416
|
${MONGODB_PROMPT}
|
|
@@ -427,7 +427,7 @@ import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
|
427
427
|
export const ragAgent = new Agent({
|
|
428
428
|
id: 'rag-agent',
|
|
429
429
|
name: 'RAG Agent',
|
|
430
|
-
model: 'openai/gpt-5.
|
|
430
|
+
model: 'openai/gpt-5.6-sol',
|
|
431
431
|
instructions: `
|
|
432
432
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
433
433
|
${OPENSEARCH_PROMPT}
|
|
@@ -436,6 +436,23 @@ export const ragAgent = new Agent({
|
|
|
436
436
|
})
|
|
437
437
|
```
|
|
438
438
|
|
|
439
|
+
**OracleDB**:
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
443
|
+
|
|
444
|
+
export const ragAgent = new Agent({
|
|
445
|
+
id: 'rag-agent',
|
|
446
|
+
name: 'RAG Agent',
|
|
447
|
+
model: 'openai/gpt-5.6-sol',
|
|
448
|
+
instructions: `
|
|
449
|
+
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
450
|
+
${ORACLEDB_PROMPT}
|
|
451
|
+
`,
|
|
452
|
+
tools: { vectorQueryTool },
|
|
453
|
+
})
|
|
454
|
+
```
|
|
455
|
+
|
|
439
456
|
**S3Vectors**:
|
|
440
457
|
|
|
441
458
|
```ts
|
|
@@ -444,7 +461,7 @@ import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
|
444
461
|
export const ragAgent = new Agent({
|
|
445
462
|
id: 'rag-agent',
|
|
446
463
|
name: 'RAG Agent',
|
|
447
|
-
model: 'openai/gpt-5.
|
|
464
|
+
model: 'openai/gpt-5.6-sol',
|
|
448
465
|
instructions: `
|
|
449
466
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
450
467
|
${S3VECTORS_PROMPT}
|
|
@@ -455,10 +472,10 @@ export const ragAgent = new Agent({
|
|
|
455
472
|
|
|
456
473
|
### Re-ranking
|
|
457
474
|
|
|
458
|
-
Initial vector similarity search can sometimes miss
|
|
475
|
+
Initial vector similarity search can sometimes miss detailed relevance. Re-ranking is a more computationally expensive process, but more accurate algorithm that improves results by:
|
|
459
476
|
|
|
460
477
|
- Considering word order and exact matches
|
|
461
|
-
- Applying more
|
|
478
|
+
- Applying more advanced relevance scoring
|
|
462
479
|
- Using a method called cross-attention between query and documents
|
|
463
480
|
|
|
464
481
|
Here's how to use re-ranking:
|
|
@@ -476,7 +493,7 @@ const initialResults = await pgVector.query({
|
|
|
476
493
|
// Create a relevance scorer
|
|
477
494
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
478
495
|
'relevance-scorer',
|
|
479
|
-
'openai/gpt-5.
|
|
496
|
+
'openai/gpt-5.6-sol',
|
|
480
497
|
)
|
|
481
498
|
|
|
482
499
|
// Re-rank the results
|
|
@@ -517,4 +534,4 @@ The re-ranked results combine vector similarity with semantic understanding to i
|
|
|
517
534
|
|
|
518
535
|
For more details about re-ranking, see the [rerank()](https://mastra.ai/reference/rag/rerankWithScorer) method.
|
|
519
536
|
|
|
520
|
-
For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/
|
|
537
|
+
For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/reference/rag/graph-rag-guide) documentation.
|