@mastra/vectorize 1.1.0 → 1.1.1
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 +18 -0
- package/dist/docs/SKILL.md +3 -6
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/{docs-rag-retrieval.md → reference-rag-retrieval.md} +53 -26
- package/dist/docs/references/{docs-rag-vector-databases.md → reference-rag-vector-databases.md} +70 -5
- package/dist/docs/references/reference-vectors-vectorize.md +14 -2
- package/dist/index.cjs +427 -407
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +401 -399
- package/dist/index.js.map +1 -1
- package/dist/vector/index.d.ts +9 -0
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +15 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/vectorize
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed Cloudflare Vectorize updates inserting a duplicate vector under a random ID instead of replacing the requested one, and added support for deleting multiple vectors by ID. Deleting by metadata filter remains unsupported. (#21582) ([#21694](https://github.com/mastra-ai/mastra/pull/21694))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`587f6ef`](https://github.com/mastra-ai/mastra/commit/587f6efcfc25880b93760a8607d1cd381ec612fe), [`7e096f0`](https://github.com/mastra-ai/mastra/commit/7e096f02f0dddbf09b85d306458351245ed2f886), [`d7e6745`](https://github.com/mastra-ai/mastra/commit/d7e67456954863c55440ea9c49bc6ceb9949972d), [`6223446`](https://github.com/mastra-ai/mastra/commit/6223446ddce6166e96e0ba5e00d628b615dee8ca), [`15101bb`](https://github.com/mastra-ai/mastra/commit/15101bb53c0d934f31af6b8813b88191e382a5e5), [`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`c2c3deb`](https://github.com/mastra-ai/mastra/commit/c2c3debcf670c7082d0a5e553aa99818a864698c), [`d8308a2`](https://github.com/mastra-ai/mastra/commit/d8308a2be3c07e777393d1017a381dcae3890d30), [`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`74e5bd3`](https://github.com/mastra-ai/mastra/commit/74e5bd315b8b3a1e04cb6cf480bb0f5fc4951dc8), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`8f0a332`](https://github.com/mastra-ai/mastra/commit/8f0a3321bf180368d76fe7b36aa1a8f60f00b6de), [`0b4f108`](https://github.com/mastra-ai/mastra/commit/0b4f1089aa8d92e67c2a8e99726822c5ee410784), [`9acb50f`](https://github.com/mastra-ai/mastra/commit/9acb50f71cec9c362f06820033f90ae6b1f8282f), [`46e9e3f`](https://github.com/mastra-ai/mastra/commit/46e9e3f73babe1bc70080a596cf2ac0b9da48519), [`3f9a190`](https://github.com/mastra-ai/mastra/commit/3f9a19057c027155867b9317294ee4ca7bd0581a), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`6db7a5d`](https://github.com/mastra-ai/mastra/commit/6db7a5dd3dd2b6f7ef75dcd804fcffef5fa83963), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`583e235`](https://github.com/mastra-ai/mastra/commit/583e23519c13af16c1746f9c49722d011216611b), [`b098de9`](https://github.com/mastra-ai/mastra/commit/b098de9d7cb9f672e0883a5c716465a3a689693d), [`e8808e3`](https://github.com/mastra-ai/mastra/commit/e8808e3d8eb585a2565be53e56a7e0e1477352a4), [`a77f8d4`](https://github.com/mastra-ai/mastra/commit/a77f8d4740d2178a74c41e4bf678b4fcd8fa0bb2), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`33374ba`](https://github.com/mastra-ai/mastra/commit/33374ba359e4fb13eaa918ae925fe167a3c55414), [`940bf5c`](https://github.com/mastra-ai/mastra/commit/940bf5ccf04f2c9ebd8a1390431733222a03b1cd), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588), [`ef6e295`](https://github.com/mastra-ai/mastra/commit/ef6e295b59bc25a5b61b633a89c97bcfce9fb465), [`208e1b3`](https://github.com/mastra-ai/mastra/commit/208e1b39f30f4b386e494394e9d71d96f0f90241), [`c938d34`](https://github.com/mastra-ai/mastra/commit/c938d34739936c8ecbabd67ad6a4a4396f41c4c6), [`88ddc7c`](https://github.com/mastra-ai/mastra/commit/88ddc7ce01d40175f13a3228b789a906779680bd), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`40d358e`](https://github.com/mastra-ai/mastra/commit/40d358e29d55543803e64b49241122f598ffabc7), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`e80cd7e`](https://github.com/mastra-ai/mastra/commit/e80cd7e7683e7d732e1cc6784bcac1d2640d2ce3), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`1d9a0ea`](https://github.com/mastra-ai/mastra/commit/1d9a0ea4a9901baee6cd56737243bd6d1f631ac0), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`a7dd322`](https://github.com/mastra-ai/mastra/commit/a7dd32247d95afc539f483ca37f4594af0387f59), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`b860493`](https://github.com/mastra-ai/mastra/commit/b86049391100e665d579f700c8a2034c036defc3), [`d4be8c1`](https://github.com/mastra-ai/mastra/commit/d4be8c1739d22d621e3f78790e1dd5eb5ecc3589), [`a5d2eb1`](https://github.com/mastra-ai/mastra/commit/a5d2eb10347eade1ae2816d88f466c25186c54a5), [`3667679`](https://github.com/mastra-ai/mastra/commit/3667679db057edfb086846d13369fdda4902ad65), [`49696e8`](https://github.com/mastra-ai/mastra/commit/49696e8e42f870674a0a58f5abcd22cc54dd2864), [`2ef2f23`](https://github.com/mastra-ai/mastra/commit/2ef2f230a7aed342e7dc3b2000cd42e4c43e08a7), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`20504b2`](https://github.com/mastra-ai/mastra/commit/20504b2ecebd0e077acda3d457ab57480a98ed3e), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`c5f964d`](https://github.com/mastra-ai/mastra/commit/c5f964d3f77064e978f8066ec506eed77ba5c63c), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`7aad631`](https://github.com/mastra-ai/mastra/commit/7aad631b43bc10db77d5b8c66b200d7a49d18bf2), [`512100a`](https://github.com/mastra-ai/mastra/commit/512100a7d8b7e9c920f2590c6b3612f5de0d3cff), [`e81744c`](https://github.com/mastra-ai/mastra/commit/e81744cd13c46619c142dc521dc0baac47607a84), [`f8f653f`](https://github.com/mastra-ai/mastra/commit/f8f653f10980d01a73706cc3c8689ca5e40ce808), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`9ef432b`](https://github.com/mastra-ai/mastra/commit/9ef432b6faa534b57b0d182a610e13dd9a7123ff), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`b9cf308`](https://github.com/mastra-ai/mastra/commit/b9cf30846f97f99ac1906ee8a68f4f2d117b0378), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716), [`1794a79`](https://github.com/mastra-ai/mastra/commit/1794a79178c418004a7261b1ad9114066f7ef01d), [`0cdc5dc`](https://github.com/mastra-ai/mastra/commit/0cdc5dc69024957815da4f51acc4119eb4f447d7), [`5740ec6`](https://github.com/mastra-ai/mastra/commit/5740ec60c760ffdfbfaa59d603d03b847c864e05)]:
|
|
10
|
+
- @mastra/core@1.60.0
|
|
11
|
+
|
|
12
|
+
## 1.1.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed Cloudflare Vectorize updates inserting a duplicate vector under a random ID instead of replacing the requested one, and added support for deleting multiple vectors by ID. Deleting by metadata filter remains unsupported. (#21582) ([#21694](https://github.com/mastra-ai/mastra/pull/21694))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716)]:
|
|
19
|
+
- @mastra/core@1.60.0-alpha.8
|
|
20
|
+
|
|
3
21
|
## 1.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-vectorize
|
|
|
3
3
|
description: Documentation for @mastra/vectorize. Use when working with @mastra/vectorize APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/vectorize"
|
|
6
|
-
version: "1.1.
|
|
6
|
+
version: "1.1.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -14,13 +14,10 @@ Use this skill whenever you are working with @mastra/vectorize to obtain the dom
|
|
|
14
14
|
|
|
15
15
|
Read the individual reference documents for detailed explanations and code examples.
|
|
16
16
|
|
|
17
|
-
### Docs
|
|
18
|
-
|
|
19
|
-
- [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.
|
|
20
|
-
- [Storing embeddings in a vector database](references/docs-rag-vector-databases.md) - Guide on vector storage options in Mastra, including embedded and dedicated vector databases for similarity search.
|
|
21
|
-
|
|
22
17
|
### Reference
|
|
23
18
|
|
|
19
|
+
- [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.
|
|
20
|
+
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) - Guide on vector storage options in Mastra, including embedded and dedicated vector databases for similarity search.
|
|
24
21
|
- [Reference: Cloudflare vector store](references/reference-vectors-vectorize.md) - Documentation for the CloudflareVector class in Mastra, which provides vector search using Cloudflare Vectorize.
|
|
25
22
|
|
|
26
23
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Retrieval in RAG systems
|
|
2
4
|
|
|
3
5
|
After storing embeddings, you need to retrieve relevant chunks to answer user queries.
|
|
@@ -158,15 +160,15 @@ When creating the tool, pay special attention to the tool's name and description
|
|
|
158
160
|
|
|
159
161
|
This is particularly useful when:
|
|
160
162
|
|
|
161
|
-
- Your agent needs to
|
|
163
|
+
- Your agent needs to decide at runtime what information to retrieve
|
|
162
164
|
- The retrieval process requires complex decision-making
|
|
163
165
|
- You want the agent to combine multiple retrieval strategies based on context
|
|
164
166
|
|
|
165
167
|
#### Database-Specific Configurations
|
|
166
168
|
|
|
167
|
-
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.
|
|
168
170
|
|
|
169
|
-
> **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.
|
|
170
172
|
>
|
|
171
173
|
> Connection credentials (URLs, auth tokens) are configured when you instantiate the vector store class (e.g., `new LibSQLVector({ url: '...' })`).
|
|
172
174
|
|
|
@@ -233,7 +235,7 @@ const lanceQueryTool = createVectorQueryTool({
|
|
|
233
235
|
- **pgVector optimization**: Control search accuracy and speed with ef/probes parameters
|
|
234
236
|
- **Quality filtering**: Set minimum similarity thresholds to improve result relevance
|
|
235
237
|
- **LanceDB tables**: Separate data into tables for better organization and performance
|
|
236
|
-
- **Runtime flexibility**: Override configurations
|
|
238
|
+
- **Runtime flexibility**: Override configurations at runtime based on context
|
|
237
239
|
|
|
238
240
|
**Common Use Cases:**
|
|
239
241
|
|
|
@@ -264,6 +266,23 @@ For detailed configuration options and advanced usage, see the [Vector Query Too
|
|
|
264
266
|
|
|
265
267
|
Vector store prompts define query patterns and filtering capabilities for each vector database implementation. When implementing filtering, these prompts are required in the agent's instructions to specify valid operators and syntax for each vector store implementation.
|
|
266
268
|
|
|
269
|
+
**MongoDB**:
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
273
|
+
|
|
274
|
+
export const ragAgent = new Agent({
|
|
275
|
+
id: 'rag-agent',
|
|
276
|
+
name: 'RAG Agent',
|
|
277
|
+
model: 'openai/gpt-5.6-sol',
|
|
278
|
+
instructions: `
|
|
279
|
+
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
280
|
+
${MONGODB_PROMPT}
|
|
281
|
+
`,
|
|
282
|
+
tools: { vectorQueryTool },
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
267
286
|
**pgVector**:
|
|
268
287
|
|
|
269
288
|
```ts
|
|
@@ -272,7 +291,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
272
291
|
export const ragAgent = new Agent({
|
|
273
292
|
id: 'rag-agent',
|
|
274
293
|
name: 'RAG Agent',
|
|
275
|
-
model: 'openai/gpt-5.
|
|
294
|
+
model: 'openai/gpt-5.6-sol',
|
|
276
295
|
instructions: `
|
|
277
296
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
278
297
|
${PGVECTOR_PROMPT}
|
|
@@ -289,7 +308,7 @@ import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
|
289
308
|
export const ragAgent = new Agent({
|
|
290
309
|
id: 'rag-agent',
|
|
291
310
|
name: 'RAG Agent',
|
|
292
|
-
model: 'openai/gpt-5.
|
|
311
|
+
model: 'openai/gpt-5.6-sol',
|
|
293
312
|
instructions: `
|
|
294
313
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
295
314
|
${PINECONE_PROMPT}
|
|
@@ -306,7 +325,7 @@ import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
|
306
325
|
export const ragAgent = new Agent({
|
|
307
326
|
id: 'rag-agent',
|
|
308
327
|
name: 'RAG Agent',
|
|
309
|
-
model: 'openai/gpt-5.
|
|
328
|
+
model: 'openai/gpt-5.6-sol',
|
|
310
329
|
instructions: `
|
|
311
330
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
312
331
|
${QDRANT_PROMPT}
|
|
@@ -323,7 +342,7 @@ import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
|
323
342
|
export const ragAgent = new Agent({
|
|
324
343
|
id: 'rag-agent',
|
|
325
344
|
name: 'RAG Agent',
|
|
326
|
-
model: 'openai/gpt-5.
|
|
345
|
+
model: 'openai/gpt-5.6-sol',
|
|
327
346
|
instructions: `
|
|
328
347
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
329
348
|
${CHROMA_PROMPT}
|
|
@@ -340,7 +359,7 @@ import { ASTRA_PROMPT } from '@mastra/astra'
|
|
|
340
359
|
export const ragAgent = new Agent({
|
|
341
360
|
id: 'rag-agent',
|
|
342
361
|
name: 'RAG Agent',
|
|
343
|
-
model: 'openai/gpt-5.
|
|
362
|
+
model: 'openai/gpt-5.6-sol',
|
|
344
363
|
instructions: `
|
|
345
364
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
346
365
|
${ASTRA_PROMPT}
|
|
@@ -357,7 +376,7 @@ import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
|
357
376
|
export const ragAgent = new Agent({
|
|
358
377
|
id: 'rag-agent',
|
|
359
378
|
name: 'RAG Agent',
|
|
360
|
-
model: 'openai/gpt-5.
|
|
379
|
+
model: 'openai/gpt-5.6-sol',
|
|
361
380
|
instructions: `
|
|
362
381
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
363
382
|
${LIBSQL_PROMPT}
|
|
@@ -374,7 +393,7 @@ import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
|
374
393
|
export const ragAgent = new Agent({
|
|
375
394
|
id: 'rag-agent',
|
|
376
395
|
name: 'RAG Agent',
|
|
377
|
-
model: 'openai/gpt-5.
|
|
396
|
+
model: 'openai/gpt-5.6-sol',
|
|
378
397
|
instructions: `
|
|
379
398
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
380
399
|
${UPSTASH_PROMPT}
|
|
@@ -391,7 +410,7 @@ import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
|
391
410
|
export const ragAgent = new Agent({
|
|
392
411
|
id: 'rag-agent',
|
|
393
412
|
name: 'RAG Agent',
|
|
394
|
-
model: 'openai/gpt-5.
|
|
413
|
+
model: 'openai/gpt-5.6-sol',
|
|
395
414
|
instructions: `
|
|
396
415
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
397
416
|
${VECTORIZE_PROMPT}
|
|
@@ -400,35 +419,35 @@ export const ragAgent = new Agent({
|
|
|
400
419
|
})
|
|
401
420
|
```
|
|
402
421
|
|
|
403
|
-
**
|
|
422
|
+
**OpenSearch**:
|
|
404
423
|
|
|
405
424
|
```ts
|
|
406
|
-
import {
|
|
425
|
+
import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
407
426
|
|
|
408
427
|
export const ragAgent = new Agent({
|
|
409
428
|
id: 'rag-agent',
|
|
410
429
|
name: 'RAG Agent',
|
|
411
|
-
model: 'openai/gpt-5.
|
|
430
|
+
model: 'openai/gpt-5.6-sol',
|
|
412
431
|
instructions: `
|
|
413
432
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
414
|
-
${
|
|
433
|
+
${OPENSEARCH_PROMPT}
|
|
415
434
|
`,
|
|
416
435
|
tools: { vectorQueryTool },
|
|
417
436
|
})
|
|
418
437
|
```
|
|
419
438
|
|
|
420
|
-
**
|
|
439
|
+
**OracleDB**:
|
|
421
440
|
|
|
422
441
|
```ts
|
|
423
|
-
import {
|
|
442
|
+
import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
424
443
|
|
|
425
444
|
export const ragAgent = new Agent({
|
|
426
445
|
id: 'rag-agent',
|
|
427
446
|
name: 'RAG Agent',
|
|
428
|
-
model: 'openai/gpt-5.
|
|
447
|
+
model: 'openai/gpt-5.6-sol',
|
|
429
448
|
instructions: `
|
|
430
449
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
431
|
-
${
|
|
450
|
+
${ORACLEDB_PROMPT}
|
|
432
451
|
`,
|
|
433
452
|
tools: { vectorQueryTool },
|
|
434
453
|
})
|
|
@@ -442,7 +461,7 @@ import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
|
442
461
|
export const ragAgent = new Agent({
|
|
443
462
|
id: 'rag-agent',
|
|
444
463
|
name: 'RAG Agent',
|
|
445
|
-
model: 'openai/gpt-5.
|
|
464
|
+
model: 'openai/gpt-5.6-sol',
|
|
446
465
|
instructions: `
|
|
447
466
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
448
467
|
${S3VECTORS_PROMPT}
|
|
@@ -453,10 +472,10 @@ export const ragAgent = new Agent({
|
|
|
453
472
|
|
|
454
473
|
### Re-ranking
|
|
455
474
|
|
|
456
|
-
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:
|
|
457
476
|
|
|
458
477
|
- Considering word order and exact matches
|
|
459
|
-
- Applying more
|
|
478
|
+
- Applying more advanced relevance scoring
|
|
460
479
|
- Using a method called cross-attention between query and documents
|
|
461
480
|
|
|
462
481
|
Here's how to use re-ranking:
|
|
@@ -474,7 +493,7 @@ const initialResults = await pgVector.query({
|
|
|
474
493
|
// Create a relevance scorer
|
|
475
494
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
476
495
|
'relevance-scorer',
|
|
477
|
-
'openai/gpt-5.
|
|
496
|
+
'openai/gpt-5.6-sol',
|
|
478
497
|
)
|
|
479
498
|
|
|
480
499
|
// Re-rank the results
|
|
@@ -501,7 +520,13 @@ The weights control how different factors influence the final ranking:
|
|
|
501
520
|
|
|
502
521
|
> **Note:** For semantic scoring to work properly during re-ranking, each result must include the text content in its `metadata.text` field.
|
|
503
522
|
|
|
504
|
-
You can also use other relevance score providers like Cohere or ZeroEntropy:
|
|
523
|
+
You can also use other relevance score providers like Voyage AI, Cohere, or ZeroEntropy:
|
|
524
|
+
|
|
525
|
+
```ts
|
|
526
|
+
import { VoyageRelevanceScorer } from '@mastra/voyageai'
|
|
527
|
+
|
|
528
|
+
const relevanceProvider = new VoyageRelevanceScorer({ model: 'rerank-2.5' })
|
|
529
|
+
```
|
|
505
530
|
|
|
506
531
|
```ts
|
|
507
532
|
const relevanceProvider = new CohereRelevanceScorer('rerank-v3.5')
|
|
@@ -511,8 +536,10 @@ const relevanceProvider = new CohereRelevanceScorer('rerank-v3.5')
|
|
|
511
536
|
const relevanceProvider = new ZeroEntropyRelevanceScorer('zerank-1')
|
|
512
537
|
```
|
|
513
538
|
|
|
539
|
+
Voyage AI provides dedicated reranking models: `rerank-2.5` and `rerank-2.5-lite` both allow up to 32,000 tokens for the query and any single document combined, and up to 600,000 tokens across a request. `VoyageRelevanceScorer` reads `VOYAGE_API_KEY` from the environment, or accepts an `apiKey` in its config.
|
|
540
|
+
|
|
514
541
|
The re-ranked results combine vector similarity with semantic understanding to improve retrieval quality.
|
|
515
542
|
|
|
516
543
|
For more details about re-ranking, see the [rerank()](https://mastra.ai/reference/rag/rerankWithScorer) method.
|
|
517
544
|
|
|
518
|
-
For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/
|
|
545
|
+
For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/reference/rag/graph-rag-guide) documentation.
|
package/dist/docs/references/{docs-rag-vector-databases.md → reference-rag-vector-databases.md}
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Storing embeddings in a vector database
|
|
2
4
|
|
|
3
|
-
After generating embeddings, you need to store them in a database that supports vector similarity search. Mastra provides a consistent interface for storing and querying embeddings across
|
|
5
|
+
After generating embeddings, you need to store them in a database that supports vector similarity search. Mastra provides a consistent interface for storing and querying embeddings across vector databases.
|
|
4
6
|
|
|
5
7
|
## Supported databases
|
|
6
8
|
|
|
@@ -12,7 +14,7 @@ import { MongoDBVector } from '@mastra/mongodb'
|
|
|
12
14
|
const store = new MongoDBVector({
|
|
13
15
|
id: 'mongodb-vector',
|
|
14
16
|
uri: process.env.MONGODB_URI,
|
|
15
|
-
dbName: process.env.
|
|
17
|
+
dbName: process.env.MONGODB_DB_NAME,
|
|
16
18
|
})
|
|
17
19
|
await store.createIndex({
|
|
18
20
|
indexName: 'myCollection',
|
|
@@ -25,10 +27,31 @@ await store.upsert({
|
|
|
25
27
|
})
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
### Using MongoDB Atlas Vector
|
|
30
|
+
### Using MongoDB Atlas Vector Search
|
|
29
31
|
|
|
30
32
|
For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel\&utm_source=third-party-content\&utm_medium=cta\&utm_content=mastra-docs).
|
|
31
33
|
|
|
34
|
+
### Using VoyageAI with MongoDB
|
|
35
|
+
|
|
36
|
+
MongoDB works seamlessly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb).
|
|
37
|
+
|
|
38
|
+
### Hybrid Search (Vector + Full-Text)
|
|
39
|
+
|
|
40
|
+
MongoDB supports hybrid search that fuses vector similarity with BM25 full-text search using server-side `$rankFusion` (requires MongoDB >= 8.0; generally available from 8.1, and enabled on Atlas 8.0.x). This is useful when you want to combine semantic and keyword-based retrieval:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
await store.createSearchIndex({ indexName: 'myCollection', fields: ['text'] })
|
|
44
|
+
const results = await store.hybridQuery({
|
|
45
|
+
indexName: 'myCollection',
|
|
46
|
+
queryVector: embedding,
|
|
47
|
+
query: 'search terms',
|
|
48
|
+
paths: ['text'],
|
|
49
|
+
topK: 10,
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
|
|
54
|
+
|
|
32
55
|
**PgVector**:
|
|
33
56
|
|
|
34
57
|
```ts
|
|
@@ -55,6 +78,35 @@ await store.upsert({
|
|
|
55
78
|
|
|
56
79
|
PostgreSQL with the pgvector extension is a good solution for teams already using PostgreSQL who want to minimize infrastructure complexity. For detailed setup instructions and best practices, see the [official pgvector repository](https://github.com/pgvector/pgvector).
|
|
57
80
|
|
|
81
|
+
**OracleDB**:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { OracleVector } from '@mastra/oracledb'
|
|
85
|
+
|
|
86
|
+
const store = new OracleVector({
|
|
87
|
+
id: 'oracle-vector',
|
|
88
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
89
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
90
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
await store.createIndex({
|
|
94
|
+
indexName: 'myCollection',
|
|
95
|
+
dimension: 1536,
|
|
96
|
+
indexConfig: { type: 'none' },
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
await store.upsert({
|
|
100
|
+
indexName: 'myCollection',
|
|
101
|
+
vectors: embeddings,
|
|
102
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
103
|
+
})
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Using Oracle Database Vector Search
|
|
107
|
+
|
|
108
|
+
OracleDB stores embeddings in native `VECTOR` columns and metadata in Oracle JSON. Exact search is the default; HNSW and IVF indexes can be configured for tuned deployments.
|
|
109
|
+
|
|
58
110
|
**Pinecone**:
|
|
59
111
|
|
|
60
112
|
```ts
|
|
@@ -355,8 +407,9 @@ await store.createIndex({
|
|
|
355
407
|
|
|
356
408
|
The dimension size must match the output dimension of your chosen embedding model. Common dimension sizes are:
|
|
357
409
|
|
|
358
|
-
-
|
|
410
|
+
- OpenAI `text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
|
|
359
411
|
- `Cohere embed-multilingual-v3`: 1024 dimensions
|
|
412
|
+
- `VoyageAI voyage-3.5`: 1024 dimensions (or custom: 256, 512, 1024, 2048)
|
|
360
413
|
- `Google gemini-embedding-001`: 768 dimensions (or custom)
|
|
361
414
|
|
|
362
415
|
> **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
|
|
@@ -386,6 +439,18 @@ Index names must:
|
|
|
386
439
|
- Example: `my_index_123` is valid
|
|
387
440
|
- Example: `my-index` is not valid (contains hyphen)
|
|
388
441
|
|
|
442
|
+
**OracleDB**:
|
|
443
|
+
|
|
444
|
+
Index names are logical Mastra names. OracleDB maps each logical index to a physical Oracle table internally.
|
|
445
|
+
|
|
446
|
+
Logical index names must:
|
|
447
|
+
|
|
448
|
+
- Be non-empty
|
|
449
|
+
- Be 512 characters or fewer
|
|
450
|
+
- Be stable for the lifetime of the vector index
|
|
451
|
+
- Example: `my_collection_123` is valid
|
|
452
|
+
- Example: `customer-support/docs:v1` is valid and is mapped to a safe Oracle table name
|
|
453
|
+
|
|
389
454
|
**Pinecone**:
|
|
390
455
|
|
|
391
456
|
Index names must:
|
|
@@ -547,7 +612,7 @@ The upsert operation:
|
|
|
547
612
|
|
|
548
613
|
Vector stores support rich metadata (any JSON-serializable fields) for filtering and organization. Since metadata is stored with no fixed schema, use consistent field naming to avoid unexpected query results.
|
|
549
614
|
|
|
550
|
-
> **Warning:** Metadata is
|
|
615
|
+
> **Warning:** Metadata is important for vector storage. Without it, you'd only have numerical embeddings with no way to return the original text or filter results. Always store at least the source text as metadata.
|
|
551
616
|
|
|
552
617
|
```ts
|
|
553
618
|
// Store embeddings with rich metadata for better organization and filtering
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Cloudflare vector store
|
|
2
4
|
|
|
3
5
|
The CloudflareVector class provides vector search using [Cloudflare Vectorize](https://developers.cloudflare.com/vectorize/), a vector database service integrated with Cloudflare's edge network.
|
|
@@ -88,13 +90,13 @@ Lists all metadata field indexes for an index.
|
|
|
88
90
|
|
|
89
91
|
### `updateVector()`
|
|
90
92
|
|
|
91
|
-
Updates
|
|
93
|
+
Updates the vector and optionally the metadata for a specific ID within an index. Vectorize has no partial-update operation, so `update.vector` is required. Metadata-only updates aren't supported and throw an error.
|
|
92
94
|
|
|
93
95
|
**indexName** (`string`): Name of the index containing the ID to update
|
|
94
96
|
|
|
95
97
|
**id** (`string`): Unique identifier of the vector or metadata to update
|
|
96
98
|
|
|
97
|
-
**update** (`{ vector
|
|
99
|
+
**update** (`{ vector: number[]; metadata?: Record<string, any>; }`): Object containing the new vector values, and optionally the metadata to update. The vector values are required
|
|
98
100
|
|
|
99
101
|
### `deleteVector()`
|
|
100
102
|
|
|
@@ -104,6 +106,16 @@ Deletes a vector and its associated metadata for a specific ID within an index.
|
|
|
104
106
|
|
|
105
107
|
**id** (`string`): Unique identifier of the vector and metadata to delete
|
|
106
108
|
|
|
109
|
+
### `deleteVectors()`
|
|
110
|
+
|
|
111
|
+
Deletes multiple vectors and their associated metadata by ID. Vectorize has no filtered-delete operation, so deleting by metadata filter isn't supported and throws an error.
|
|
112
|
+
|
|
113
|
+
**indexName** (`string`): Name of the index containing the vectors to delete
|
|
114
|
+
|
|
115
|
+
**ids** (`string[]`): Unique identifiers of the vectors to delete. Must contain at least one ID, and cannot be combined with filter
|
|
116
|
+
|
|
117
|
+
**filter** (`Record<string, any>`): Not supported by Vectorize. Passing a filter throws an error
|
|
118
|
+
|
|
107
119
|
## Response types
|
|
108
120
|
|
|
109
121
|
Query results are returned in this format:
|