@mastra/qdrant 1.1.1 → 1.1.2
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 +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-rag-retrieval.md +20 -18
- package/dist/docs/references/docs-rag-vector-databases.md +28 -4
- package/dist/docs/references/reference-vectors-qdrant.md +4 -2
- package/dist/index.cjs +930 -1056
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +927 -1052
- package/dist/index.js.map +1 -1
- package/package.json +17 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/qdrant
|
|
2
2
|
|
|
3
|
+
## 1.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dependencies updates: ([#19779](https://github.com/mastra-ai/mastra/pull/19779))
|
|
8
|
+
- Updated dependency [`@qdrant/js-client-rest@^1.18.0` ↗︎](https://www.npmjs.com/package/@qdrant/js-client-rest/v/1.18.0) (from `^1.17.0`, in `dependencies`)
|
|
9
|
+
- Updated dependencies [[`3f472b4`](https://github.com/mastra-ai/mastra/commit/3f472b468892a1ff14ccb43cc0343b86f7d8fd7d), [`ba369f2`](https://github.com/mastra-ai/mastra/commit/ba369f2a0aaf998da0d6aa033d26f64f96bef8ac), [`35b929b`](https://github.com/mastra-ai/mastra/commit/35b929b7abc3d20d85c7985880960ac2d04a6c86), [`55c9e24`](https://github.com/mastra-ai/mastra/commit/55c9e248c27c1d72b5bb7e94ea6b8a3999eee49f), [`dcfed93`](https://github.com/mastra-ai/mastra/commit/dcfed93e1e256c6abfa792cbb7ca836f5d0e8638), [`2876e15`](https://github.com/mastra-ai/mastra/commit/2876e15b4d2f616a3bc1ed3af57d546c268384ce), [`9b3626a`](https://github.com/mastra-ai/mastra/commit/9b3626aeb1d16fcd34b0a8e94c114ddb80a3b240), [`4696963`](https://github.com/mastra-ai/mastra/commit/469696312ac4c618bc8475b0c5ed7949b8a3455e), [`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73), [`07f5b4b`](https://github.com/mastra-ai/mastra/commit/07f5b4ba9d608d88865030732e580298296adf99), [`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73), [`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73), [`598080f`](https://github.com/mastra-ai/mastra/commit/598080f224edb3f0f5b801035b067fac50a56a03)]:
|
|
10
|
+
- @mastra/core@1.55.0
|
|
11
|
+
|
|
12
|
+
## 1.1.2-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- dependencies updates: ([#19779](https://github.com/mastra-ai/mastra/pull/19779))
|
|
17
|
+
- Updated dependency [`@qdrant/js-client-rest@^1.18.0` ↗︎](https://www.npmjs.com/package/@qdrant/js-client-rest/v/1.18.0) (from `^1.17.0`, in `dependencies`)
|
|
18
|
+
- Updated dependencies [[`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73), [`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73), [`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73)]:
|
|
19
|
+
- @mastra/core@1.55.0-alpha.3
|
|
20
|
+
|
|
3
21
|
## 1.1.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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
|
|
|
@@ -272,7 +274,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
272
274
|
export const ragAgent = new Agent({
|
|
273
275
|
id: 'rag-agent',
|
|
274
276
|
name: 'RAG Agent',
|
|
275
|
-
model: 'openai/gpt-5.
|
|
277
|
+
model: 'openai/gpt-5.6-sol',
|
|
276
278
|
instructions: `
|
|
277
279
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
278
280
|
${PGVECTOR_PROMPT}
|
|
@@ -289,7 +291,7 @@ import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
|
289
291
|
export const ragAgent = new Agent({
|
|
290
292
|
id: 'rag-agent',
|
|
291
293
|
name: 'RAG Agent',
|
|
292
|
-
model: 'openai/gpt-5.
|
|
294
|
+
model: 'openai/gpt-5.6-sol',
|
|
293
295
|
instructions: `
|
|
294
296
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
295
297
|
${PINECONE_PROMPT}
|
|
@@ -306,7 +308,7 @@ import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
|
306
308
|
export const ragAgent = new Agent({
|
|
307
309
|
id: 'rag-agent',
|
|
308
310
|
name: 'RAG Agent',
|
|
309
|
-
model: 'openai/gpt-5.
|
|
311
|
+
model: 'openai/gpt-5.6-sol',
|
|
310
312
|
instructions: `
|
|
311
313
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
312
314
|
${QDRANT_PROMPT}
|
|
@@ -323,7 +325,7 @@ import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
|
323
325
|
export const ragAgent = new Agent({
|
|
324
326
|
id: 'rag-agent',
|
|
325
327
|
name: 'RAG Agent',
|
|
326
|
-
model: 'openai/gpt-5.
|
|
328
|
+
model: 'openai/gpt-5.6-sol',
|
|
327
329
|
instructions: `
|
|
328
330
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
329
331
|
${CHROMA_PROMPT}
|
|
@@ -340,7 +342,7 @@ import { ASTRA_PROMPT } from '@mastra/astra'
|
|
|
340
342
|
export const ragAgent = new Agent({
|
|
341
343
|
id: 'rag-agent',
|
|
342
344
|
name: 'RAG Agent',
|
|
343
|
-
model: 'openai/gpt-5.
|
|
345
|
+
model: 'openai/gpt-5.6-sol',
|
|
344
346
|
instructions: `
|
|
345
347
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
346
348
|
${ASTRA_PROMPT}
|
|
@@ -357,7 +359,7 @@ import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
|
357
359
|
export const ragAgent = new Agent({
|
|
358
360
|
id: 'rag-agent',
|
|
359
361
|
name: 'RAG Agent',
|
|
360
|
-
model: 'openai/gpt-5.
|
|
362
|
+
model: 'openai/gpt-5.6-sol',
|
|
361
363
|
instructions: `
|
|
362
364
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
363
365
|
${LIBSQL_PROMPT}
|
|
@@ -374,7 +376,7 @@ import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
|
374
376
|
export const ragAgent = new Agent({
|
|
375
377
|
id: 'rag-agent',
|
|
376
378
|
name: 'RAG Agent',
|
|
377
|
-
model: 'openai/gpt-5.
|
|
379
|
+
model: 'openai/gpt-5.6-sol',
|
|
378
380
|
instructions: `
|
|
379
381
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
380
382
|
${UPSTASH_PROMPT}
|
|
@@ -391,7 +393,7 @@ import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
|
391
393
|
export const ragAgent = new Agent({
|
|
392
394
|
id: 'rag-agent',
|
|
393
395
|
name: 'RAG Agent',
|
|
394
|
-
model: 'openai/gpt-5.
|
|
396
|
+
model: 'openai/gpt-5.6-sol',
|
|
395
397
|
instructions: `
|
|
396
398
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
397
399
|
${VECTORIZE_PROMPT}
|
|
@@ -408,7 +410,7 @@ import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
|
408
410
|
export const ragAgent = new Agent({
|
|
409
411
|
id: 'rag-agent',
|
|
410
412
|
name: 'RAG Agent',
|
|
411
|
-
model: 'openai/gpt-5.
|
|
413
|
+
model: 'openai/gpt-5.6-sol',
|
|
412
414
|
instructions: `
|
|
413
415
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
414
416
|
${MONGODB_PROMPT}
|
|
@@ -425,7 +427,7 @@ import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
|
425
427
|
export const ragAgent = new Agent({
|
|
426
428
|
id: 'rag-agent',
|
|
427
429
|
name: 'RAG Agent',
|
|
428
|
-
model: 'openai/gpt-5.
|
|
430
|
+
model: 'openai/gpt-5.6-sol',
|
|
429
431
|
instructions: `
|
|
430
432
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
431
433
|
${OPENSEARCH_PROMPT}
|
|
@@ -442,7 +444,7 @@ import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
|
442
444
|
export const ragAgent = new Agent({
|
|
443
445
|
id: 'rag-agent',
|
|
444
446
|
name: 'RAG Agent',
|
|
445
|
-
model: 'openai/gpt-5.
|
|
447
|
+
model: 'openai/gpt-5.6-sol',
|
|
446
448
|
instructions: `
|
|
447
449
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
448
450
|
${S3VECTORS_PROMPT}
|
|
@@ -453,10 +455,10 @@ export const ragAgent = new Agent({
|
|
|
453
455
|
|
|
454
456
|
### Re-ranking
|
|
455
457
|
|
|
456
|
-
Initial vector similarity search can sometimes miss
|
|
458
|
+
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
459
|
|
|
458
460
|
- Considering word order and exact matches
|
|
459
|
-
- Applying more
|
|
461
|
+
- Applying more advanced relevance scoring
|
|
460
462
|
- Using a method called cross-attention between query and documents
|
|
461
463
|
|
|
462
464
|
Here's how to use re-ranking:
|
|
@@ -474,7 +476,7 @@ const initialResults = await pgVector.query({
|
|
|
474
476
|
// Create a relevance scorer
|
|
475
477
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
476
478
|
'relevance-scorer',
|
|
477
|
-
'openai/gpt-5.
|
|
479
|
+
'openai/gpt-5.6-sol',
|
|
478
480
|
)
|
|
479
481
|
|
|
480
482
|
// Re-rank the results
|
|
@@ -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
|
|
@@ -357,6 +380,7 @@ The dimension size must match the output dimension of your chosen embedding mode
|
|
|
357
380
|
|
|
358
381
|
- `OpenAI text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
|
|
359
382
|
- `Cohere embed-multilingual-v3`: 1024 dimensions
|
|
383
|
+
- `VoyageAI voyage-3.5`: 1024 dimensions (or custom: 256, 512, 1024, 2048)
|
|
360
384
|
- `Google gemini-embedding-001`: 768 dimensions (or custom)
|
|
361
385
|
|
|
362
386
|
> **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
|
|
@@ -547,7 +571,7 @@ The upsert operation:
|
|
|
547
571
|
|
|
548
572
|
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
573
|
|
|
550
|
-
> **Warning:** Metadata is
|
|
574
|
+
> **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
575
|
|
|
552
576
|
```ts
|
|
553
577
|
// 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
|
# Qdrant vector store
|
|
2
4
|
|
|
3
5
|
The QdrantVector class provides vector search using [Qdrant](https://qdrant.tech/), a vector similarity search engine. It provides a production-ready service with a convenient API to store, search, and manage vectors with additional payload and extended filtering support.
|
|
@@ -84,7 +86,7 @@ await store.upsert({
|
|
|
84
86
|
|
|
85
87
|
#### Named Vectors
|
|
86
88
|
|
|
87
|
-
Qdrant supports [
|
|
89
|
+
Qdrant supports [multiple vectors per collection](https://qdrant.tech/documentation/concepts/vectors/#named-vectors), with a name assigned to each vector field. Use the `using` parameter to select the vector field to query:
|
|
88
90
|
|
|
89
91
|
```typescript
|
|
90
92
|
const results = await store.query({
|
|
@@ -129,7 +131,7 @@ Update a single vector by ID or by metadata filter. Either `id` or `filter` must
|
|
|
129
131
|
|
|
130
132
|
**update** (`{ vector?: number[]; metadata?: Record<string, any>; }`): Object containing the vector and/or metadata to update
|
|
131
133
|
|
|
132
|
-
Updates a vector and/or its metadata in the specified index. If both vector and metadata are provided, both will be updated.
|
|
134
|
+
Updates a vector and/or its metadata in the specified index. If both vector and metadata are provided, both will be updated. Providing either value updates that value alone.
|
|
133
135
|
|
|
134
136
|
### `deleteVector()`
|
|
135
137
|
|