@mastra/pinecone 1.1.1 → 1.1.2-alpha.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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-memory-processors.md +9 -6
- package/dist/docs/references/reference-rag-retrieval.md +7 -5
- package/dist/docs/references/reference-rag-vector-databases.md +98 -2
- package/dist/docs/references/reference-vectors-pinecone.md +8 -4
- package/package.json +8 -8
package/dist/docs/SKILL.md
CHANGED
|
@@ -14,6 +14,12 @@ Memory processors are [processors](https://mastra.ai/docs/agents/processors) tha
|
|
|
14
14
|
|
|
15
15
|
Mastra automatically adds these processors when memory is enabled:
|
|
16
16
|
|
|
17
|
+
### `MemoryInputFilter`
|
|
18
|
+
|
|
19
|
+
Trims client-echoed history before memory loaders run. For an existing thread, it keeps only the current user turn or new tool results. For an empty thread, it keeps the full initial input and removes provider item metadata from assistant parts that could refer to items that don't exist in storage.
|
|
20
|
+
|
|
21
|
+
This processor runs first so `MessageHistory`, `SemanticRecall`, and Observational Memory receive only the new input they need.
|
|
22
|
+
|
|
17
23
|
### `MessageHistory`
|
|
18
24
|
|
|
19
25
|
Retrieves message history and persists new messages.
|
|
@@ -93,7 +99,7 @@ import { Agent } from '@mastra/core/agent'
|
|
|
93
99
|
import { Memory } from '@mastra/memory'
|
|
94
100
|
import { LibSQLStore } from '@mastra/libsql'
|
|
95
101
|
import { PineconeVector } from '@mastra/pinecone'
|
|
96
|
-
import {
|
|
102
|
+
import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
|
|
97
103
|
import { openai } from '@ai-sdk/openai'
|
|
98
104
|
|
|
99
105
|
const agent = new Agent({
|
|
@@ -109,10 +115,7 @@ const agent = new Agent({
|
|
|
109
115
|
id: 'memory-vector',
|
|
110
116
|
apiKey: process.env.PINECONE_API_KEY!,
|
|
111
117
|
}),
|
|
112
|
-
embedder: new
|
|
113
|
-
model: 'text-embedding-3-small',
|
|
114
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
115
|
-
}),
|
|
118
|
+
embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
|
|
116
119
|
semanticRecall: { enabled: true }, // SemanticRecall processor automatically added
|
|
117
120
|
}),
|
|
118
121
|
})
|
|
@@ -206,7 +209,7 @@ Understanding the execution order is important when combining guardrails with me
|
|
|
206
209
|
[Memory Processors] → [Your inputProcessors]
|
|
207
210
|
```
|
|
208
211
|
|
|
209
|
-
1. **Memory processors run FIRST**: `WorkingMemory`, `MessageHistory`, `SemanticRecall`
|
|
212
|
+
1. **Memory processors run FIRST**: `MemoryInputFilter`, then `WorkingMemory`, `MessageHistory`, and `SemanticRecall`
|
|
210
213
|
2. **Your input processors run AFTER**: guardrails, filters, validators
|
|
211
214
|
|
|
212
215
|
As a result, memory loads message history before your processors can validate or filter the input.
|
|
@@ -50,23 +50,25 @@ console.log(results)
|
|
|
50
50
|
|
|
51
51
|
The `topK` parameter specifies the maximum number of most similar results to return from the vector search.
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Each result includes an `id`, a similarity `score`, and the stored `metadata`. When you store chunk text in metadata, it's available as `metadata.text`:
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
56
|
[
|
|
57
57
|
{
|
|
58
|
-
|
|
58
|
+
id: 'chunk-1',
|
|
59
59
|
score: 0.89,
|
|
60
|
-
metadata: { source: 'article1.txt' },
|
|
60
|
+
metadata: { text: 'Climate change poses significant challenges...', source: 'article1.txt' },
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
|
|
63
|
+
id: 'chunk-2',
|
|
64
64
|
score: 0.82,
|
|
65
|
-
metadata: { source: 'article1.txt' },
|
|
65
|
+
metadata: { text: 'Rising temperatures affect crop yields...', source: 'article1.txt' },
|
|
66
66
|
},
|
|
67
67
|
]
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
Results can also include `vector` when you set `includeVector: true`, and `document` when the store returns the original document (Chroma only).
|
|
71
|
+
|
|
70
72
|
## Advanced retrieval options
|
|
71
73
|
|
|
72
74
|
### Metadata Filtering
|
|
@@ -54,6 +54,29 @@ const results = await store.hybridQuery({
|
|
|
54
54
|
|
|
55
55
|
See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
|
|
56
56
|
|
|
57
|
+
### Automated Embedding
|
|
58
|
+
|
|
59
|
+
MongoDB can generate the embeddings itself, so you don't need an embedding provider in your application. Create the index with `autoEmbed` and a Voyage AI model, write plain text, and search with a query string:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
await store.createIndex({
|
|
63
|
+
indexName: 'myCollection',
|
|
64
|
+
autoEmbed: { model: 'voyage-4' },
|
|
65
|
+
})
|
|
66
|
+
await store.upsert({
|
|
67
|
+
indexName: 'myCollection',
|
|
68
|
+
documents: chunks.map(chunk => chunk.text),
|
|
69
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
70
|
+
})
|
|
71
|
+
const results = await store.query({
|
|
72
|
+
indexName: 'myCollection',
|
|
73
|
+
queryText: 'search terms',
|
|
74
|
+
topK: 10,
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for the supported options and requirements.
|
|
79
|
+
|
|
57
80
|
**PgVector**:
|
|
58
81
|
|
|
59
82
|
```ts
|
|
@@ -207,7 +230,7 @@ await store.upsert({
|
|
|
207
230
|
**libSQL**:
|
|
208
231
|
|
|
209
232
|
```ts
|
|
210
|
-
import { LibSQLVector } from '@mastra/
|
|
233
|
+
import { LibSQLVector } from '@mastra/libsql'
|
|
211
234
|
|
|
212
235
|
const store = new LibSQLVector({
|
|
213
236
|
id: 'libsql-vector',
|
|
@@ -248,6 +271,34 @@ await store.upsert({
|
|
|
248
271
|
})
|
|
249
272
|
```
|
|
250
273
|
|
|
274
|
+
**Weaviate**:
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
import { WeaviateVector } from '@mastra/weaviate'
|
|
278
|
+
|
|
279
|
+
const store = new WeaviateVector({
|
|
280
|
+
id: 'weaviate-vector',
|
|
281
|
+
httpHost: process.env.WEAVIATE_HOST,
|
|
282
|
+
httpPort: 443,
|
|
283
|
+
httpSecure: true,
|
|
284
|
+
grpcHost: process.env.WEAVIATE_GRPC_HOST,
|
|
285
|
+
grpcPort: 443,
|
|
286
|
+
grpcSecure: true,
|
|
287
|
+
apiKey: process.env.WEAVIATE_API_KEY,
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
await store.createIndex({
|
|
291
|
+
indexName: 'myCollection',
|
|
292
|
+
dimension: 1536,
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
await store.upsert({
|
|
296
|
+
indexName: 'myCollection',
|
|
297
|
+
vectors: embeddings,
|
|
298
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
299
|
+
})
|
|
300
|
+
```
|
|
301
|
+
|
|
251
302
|
**Cloudflare**:
|
|
252
303
|
|
|
253
304
|
```ts
|
|
@@ -317,6 +368,29 @@ await store.upsert({
|
|
|
317
368
|
|
|
318
369
|
For detailed setup instructions and best practices, see the [official Elasticsearch documentation](https://www.elastic.co/docs/solutions/search/get-started).
|
|
319
370
|
|
|
371
|
+
**Azure AI Search**:
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
import { AzureAISearchVector } from '@mastra/azure-ai-search'
|
|
375
|
+
|
|
376
|
+
const store = new AzureAISearchVector({
|
|
377
|
+
id: 'azure-search-vectors',
|
|
378
|
+
endpoint: process.env.AZURE_AI_SEARCH_ENDPOINT!,
|
|
379
|
+
credential: process.env.AZURE_AI_SEARCH_CREDENTIAL!,
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
await store.createIndex({
|
|
383
|
+
indexName: 'my-collection',
|
|
384
|
+
dimension: 1536,
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
await store.upsert({
|
|
388
|
+
indexName: 'my-collection',
|
|
389
|
+
vectors: embeddings,
|
|
390
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
391
|
+
})
|
|
392
|
+
```
|
|
393
|
+
|
|
320
394
|
**Couchbase**:
|
|
321
395
|
|
|
322
396
|
```ts
|
|
@@ -534,6 +608,17 @@ Namespace names must:
|
|
|
534
608
|
|
|
535
609
|
- Example: `_namespace` isn't valid (starts with underscore)
|
|
536
610
|
|
|
611
|
+
**Weaviate**:
|
|
612
|
+
|
|
613
|
+
Index names map to Weaviate collections, which:
|
|
614
|
+
|
|
615
|
+
- Are capitalized by Weaviate (the first letter is upper-cased)
|
|
616
|
+
- Should contain only letters, numbers, and the `_` character
|
|
617
|
+
- Must start with a letter, since only the first character is upper-cased (a leading digit or symbol stays invalid)
|
|
618
|
+
- Preserve the original Mastra index name in the collection description, so `listIndexes()` and `describeIndex()` return the name you supplied
|
|
619
|
+
- Example: `my_collection` is stored as `My_collection` and returned as `my_collection`
|
|
620
|
+
- Example: `123_collection` isn't valid (starts with a digit)
|
|
621
|
+
|
|
537
622
|
**Cloudflare**:
|
|
538
623
|
|
|
539
624
|
Index names must:
|
|
@@ -587,6 +672,17 @@ Index names must:
|
|
|
587
672
|
- Example: `myindex-` isn't valid (ends with hyphen)
|
|
588
673
|
- Example: `MyIndex` isn't valid (contains uppercase letters)
|
|
589
674
|
|
|
675
|
+
**Azure AI Search**:
|
|
676
|
+
|
|
677
|
+
Index names must:
|
|
678
|
+
|
|
679
|
+
- Use only lowercase letters, numbers, dashes (`-`), and underscore (`_`) characters
|
|
680
|
+
- Not start or end with a dash
|
|
681
|
+
- Be between 2 and 128 characters long
|
|
682
|
+
- Example: `my-index-123` and `my_index` are valid
|
|
683
|
+
- Example: `MyIndex` isn't valid (contains uppercase letters)
|
|
684
|
+
- Example: `my-index-` isn't valid (ends with a dash)
|
|
685
|
+
|
|
590
686
|
### Upserting Embeddings
|
|
591
687
|
|
|
592
688
|
After creating an index, you can store embeddings along with their basic metadata:
|
|
@@ -650,7 +746,7 @@ Key metadata considerations:
|
|
|
650
746
|
|
|
651
747
|
## Deleting vectors
|
|
652
748
|
|
|
653
|
-
|
|
749
|
+
Use `deleteVectors` with a metadata filter to remove embeddings associated with a document. This is useful for cleaning up stale vectors after a document is deleted or updated.
|
|
654
750
|
|
|
655
751
|
### Delete by Metadata Filter
|
|
656
752
|
|
|
@@ -130,24 +130,28 @@ Query results are returned in this format:
|
|
|
130
130
|
interface QueryResult {
|
|
131
131
|
id: string
|
|
132
132
|
score: number
|
|
133
|
-
metadata
|
|
133
|
+
metadata?: Record<string, any>
|
|
134
134
|
vector?: number[] // Only included if includeVector is true
|
|
135
135
|
}
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
## Error handling
|
|
139
139
|
|
|
140
|
-
The store throws
|
|
140
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
141
141
|
|
|
142
142
|
```typescript
|
|
143
|
+
import { MastraError } from '@mastra/core/error'
|
|
144
|
+
|
|
143
145
|
try {
|
|
144
146
|
await store.query({
|
|
145
147
|
indexName: 'index_name',
|
|
146
148
|
queryVector: queryVector,
|
|
147
149
|
})
|
|
148
150
|
} catch (error) {
|
|
149
|
-
if (error instanceof
|
|
150
|
-
console.log(error.
|
|
151
|
+
if (error instanceof MastraError) {
|
|
152
|
+
console.log(error.id) // 'MASTRA_VECTOR_PINECONE_QUERY_FAILED'
|
|
153
|
+
console.log(error.domain) // 'STORAGE'
|
|
154
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
151
155
|
console.log(error.details) // Additional error context
|
|
152
156
|
}
|
|
153
157
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pinecone",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2-alpha.0",
|
|
4
4
|
"description": "Pinecone vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "22.20.1",
|
|
27
|
-
"@vitest/coverage-v8": "4.1.
|
|
28
|
-
"@vitest/ui": "4.1.
|
|
27
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
28
|
+
"@vitest/ui": "4.1.11",
|
|
29
29
|
"dotenv": "^17.4.2",
|
|
30
30
|
"eslint": "^10.7.0",
|
|
31
31
|
"tsdown": "0.22.9",
|
|
32
32
|
"tsx": "^4.23.1",
|
|
33
33
|
"typescript": "^7.0.2",
|
|
34
|
-
"vitest": "4.1.
|
|
35
|
-
"@internal/
|
|
36
|
-
"@internal/
|
|
37
|
-
"@internal/
|
|
38
|
-
"@mastra/core": "1.
|
|
34
|
+
"vitest": "4.1.11",
|
|
35
|
+
"@internal/lint": "0.0.144",
|
|
36
|
+
"@internal/types-builder": "0.0.119",
|
|
37
|
+
"@internal/storage-test-utils": "0.0.140",
|
|
38
|
+
"@mastra/core": "1.78.1-alpha.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|