@mastra/pinecone 0.2.12-alpha.0 → 0.2.12
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +28 -0
- package/dist/_tsup-dts-rollup.d.cts +1 -0
- package/dist/_tsup-dts-rollup.d.ts +1 -0
- package/dist/index.cjs +24 -9
- package/dist/index.js +24 -9
- package/package.json +3 -3
- package/src/vector/index.test.ts +62 -0
- package/src/vector/index.ts +33 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/pinecone@0.2.12-alpha.
|
|
2
|
+
> @mastra/pinecone@0.2.12-alpha.1 build /home/runner/work/mastra/mastra/stores/pinecone
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 6935ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/pinecone/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/pinecone/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 9347ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m11.02 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 665ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m10.96 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 666ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mastra/pinecone
|
|
2
2
|
|
|
3
|
+
## 0.2.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9cd1a46: [MASTRA-3338] update naming scheme for embedding index based on vector store rules and added duplicate index checks
|
|
8
|
+
- Updated dependencies [e450778]
|
|
9
|
+
- Updated dependencies [8902157]
|
|
10
|
+
- Updated dependencies [ca0dc88]
|
|
11
|
+
- Updated dependencies [526c570]
|
|
12
|
+
- Updated dependencies [d7a6a33]
|
|
13
|
+
- Updated dependencies [9cd1a46]
|
|
14
|
+
- Updated dependencies [b5d2de0]
|
|
15
|
+
- Updated dependencies [644f8ad]
|
|
16
|
+
- Updated dependencies [70dbf51]
|
|
17
|
+
- @mastra/core@0.9.3
|
|
18
|
+
|
|
19
|
+
## 0.2.12-alpha.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 9cd1a46: [MASTRA-3338] update naming scheme for embedding index based on vector store rules and added duplicate index checks
|
|
24
|
+
- Updated dependencies [e450778]
|
|
25
|
+
- Updated dependencies [8902157]
|
|
26
|
+
- Updated dependencies [ca0dc88]
|
|
27
|
+
- Updated dependencies [9cd1a46]
|
|
28
|
+
- Updated dependencies [70dbf51]
|
|
29
|
+
- @mastra/core@0.9.3-alpha.1
|
|
30
|
+
|
|
3
31
|
## 0.2.12-alpha.0
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -49,6 +49,7 @@ declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
|
49
49
|
declare class PineconeVector extends MastraVector {
|
|
50
50
|
private client;
|
|
51
51
|
constructor(apiKey: string, environment?: string);
|
|
52
|
+
get indexSeparator(): string;
|
|
52
53
|
createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
53
54
|
upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]>;
|
|
54
55
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
@@ -49,6 +49,7 @@ declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
|
49
49
|
declare class PineconeVector extends MastraVector {
|
|
50
50
|
private client;
|
|
51
51
|
constructor(apiKey: string, environment?: string);
|
|
52
|
+
get indexSeparator(): string;
|
|
52
53
|
createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
53
54
|
upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]>;
|
|
54
55
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
package/dist/index.cjs
CHANGED
|
@@ -100,23 +100,38 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
100
100
|
}
|
|
101
101
|
}) ?? baseClient;
|
|
102
102
|
}
|
|
103
|
+
get indexSeparator() {
|
|
104
|
+
return "-";
|
|
105
|
+
}
|
|
103
106
|
async createIndex(...args) {
|
|
104
107
|
const params = this.normalizeArgs("createIndex", args);
|
|
105
108
|
const { indexName, dimension, metric = "cosine" } = params;
|
|
106
109
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
107
110
|
throw new Error("Dimension must be a positive integer");
|
|
108
111
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
|
|
113
|
+
throw new Error("Metric must be one of: cosine, euclidean, dotproduct");
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
await this.client.createIndex({
|
|
117
|
+
name: indexName,
|
|
118
|
+
dimension,
|
|
119
|
+
metric,
|
|
120
|
+
spec: {
|
|
121
|
+
serverless: {
|
|
122
|
+
cloud: "aws",
|
|
123
|
+
region: "us-east-1"
|
|
124
|
+
}
|
|
117
125
|
}
|
|
126
|
+
});
|
|
127
|
+
} catch (error) {
|
|
128
|
+
const message = error?.errors?.[0]?.message || error?.message;
|
|
129
|
+
if (error.status === 409 || typeof message === "string" && (message.toLowerCase().includes("already exists") || message.toLowerCase().includes("duplicate"))) {
|
|
130
|
+
await this.validateExistingIndex(indexName, dimension, metric);
|
|
131
|
+
return;
|
|
118
132
|
}
|
|
119
|
-
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
120
135
|
}
|
|
121
136
|
async upsert(...args) {
|
|
122
137
|
const params = this.normalizeArgs("upsert", args, [
|
package/dist/index.js
CHANGED
|
@@ -98,23 +98,38 @@ var PineconeVector = class extends MastraVector {
|
|
|
98
98
|
}
|
|
99
99
|
}) ?? baseClient;
|
|
100
100
|
}
|
|
101
|
+
get indexSeparator() {
|
|
102
|
+
return "-";
|
|
103
|
+
}
|
|
101
104
|
async createIndex(...args) {
|
|
102
105
|
const params = this.normalizeArgs("createIndex", args);
|
|
103
106
|
const { indexName, dimension, metric = "cosine" } = params;
|
|
104
107
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
105
108
|
throw new Error("Dimension must be a positive integer");
|
|
106
109
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
|
|
111
|
+
throw new Error("Metric must be one of: cosine, euclidean, dotproduct");
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
await this.client.createIndex({
|
|
115
|
+
name: indexName,
|
|
116
|
+
dimension,
|
|
117
|
+
metric,
|
|
118
|
+
spec: {
|
|
119
|
+
serverless: {
|
|
120
|
+
cloud: "aws",
|
|
121
|
+
region: "us-east-1"
|
|
122
|
+
}
|
|
115
123
|
}
|
|
124
|
+
});
|
|
125
|
+
} catch (error) {
|
|
126
|
+
const message = error?.errors?.[0]?.message || error?.message;
|
|
127
|
+
if (error.status === 409 || typeof message === "string" && (message.toLowerCase().includes("already exists") || message.toLowerCase().includes("duplicate"))) {
|
|
128
|
+
await this.validateExistingIndex(indexName, dimension, metric);
|
|
129
|
+
return;
|
|
116
130
|
}
|
|
117
|
-
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
118
133
|
}
|
|
119
134
|
async upsert(...args) {
|
|
120
135
|
const params = this.normalizeArgs("upsert", args, [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pinecone",
|
|
3
|
-
"version": "0.2.12
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Pinecone vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@pinecone-database/pinecone": "^3.0.3",
|
|
24
|
-
"@mastra/core": "^0.9.3
|
|
24
|
+
"@mastra/core": "^0.9.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@microsoft/api-extractor": "^7.52.5",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"tsup": "^8.4.0",
|
|
32
32
|
"typescript": "^5.8.2",
|
|
33
33
|
"vitest": "^3.1.2",
|
|
34
|
-
"@internal/lint": "0.0.
|
|
34
|
+
"@internal/lint": "0.0.4"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
package/src/vector/index.test.ts
CHANGED
|
@@ -555,6 +555,14 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
555
555
|
});
|
|
556
556
|
|
|
557
557
|
describe('Error Handling', () => {
|
|
558
|
+
const testIndexName = 'test-index-error';
|
|
559
|
+
beforeAll(async () => {
|
|
560
|
+
await vectorDB.createIndex({ indexName: testIndexName, dimension: 3 });
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
afterAll(async () => {
|
|
564
|
+
await vectorDB.deleteIndex(testIndexName);
|
|
565
|
+
});
|
|
558
566
|
it('should handle non-existent index query gracefully', async () => {
|
|
559
567
|
const nonExistentIndex = 'non-existent-index';
|
|
560
568
|
await expect(vectorDB.query({ indexName: nonExistentIndex, queryVector: [1, 0, 0] })).rejects.toThrow();
|
|
@@ -564,6 +572,60 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
564
572
|
const wrongDimVector = [[1, 0]]; // 2D vector for 3D index
|
|
565
573
|
await expect(vectorDB.upsert({ indexName: testIndexName, vectors: wrongDimVector })).rejects.toThrow();
|
|
566
574
|
}, 500000);
|
|
575
|
+
|
|
576
|
+
it('should handle duplicate index creation gracefully', async () => {
|
|
577
|
+
const duplicateIndexName = `duplicate-test`;
|
|
578
|
+
const dimension = 768;
|
|
579
|
+
const infoSpy = vi.spyOn(vectorDB['logger'], 'info');
|
|
580
|
+
const warnSpy = vi.spyOn(vectorDB['logger'], 'warn');
|
|
581
|
+
|
|
582
|
+
try {
|
|
583
|
+
// Create index first time
|
|
584
|
+
await vectorDB.createIndex({
|
|
585
|
+
indexName: duplicateIndexName,
|
|
586
|
+
dimension,
|
|
587
|
+
metric: 'cosine',
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// Try to create with same dimensions - should not throw
|
|
591
|
+
await expect(
|
|
592
|
+
vectorDB.createIndex({
|
|
593
|
+
indexName: duplicateIndexName,
|
|
594
|
+
dimension,
|
|
595
|
+
metric: 'cosine',
|
|
596
|
+
}),
|
|
597
|
+
).resolves.not.toThrow();
|
|
598
|
+
|
|
599
|
+
expect(infoSpy).toHaveBeenCalledWith(expect.stringContaining('already exists with'));
|
|
600
|
+
|
|
601
|
+
// Try to create with same dimensions and different metric - should not throw
|
|
602
|
+
await expect(
|
|
603
|
+
vectorDB.createIndex({
|
|
604
|
+
indexName: duplicateIndexName,
|
|
605
|
+
dimension,
|
|
606
|
+
metric: 'euclidean',
|
|
607
|
+
}),
|
|
608
|
+
).resolves.not.toThrow();
|
|
609
|
+
|
|
610
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Attempted to create index with metric'));
|
|
611
|
+
|
|
612
|
+
// Try to create with different dimensions - should throw
|
|
613
|
+
await expect(
|
|
614
|
+
vectorDB.createIndex({
|
|
615
|
+
indexName: duplicateIndexName,
|
|
616
|
+
dimension: dimension + 1,
|
|
617
|
+
metric: 'cosine',
|
|
618
|
+
}),
|
|
619
|
+
).rejects.toThrow(
|
|
620
|
+
`Index "${duplicateIndexName}" already exists with ${dimension} dimensions, but ${dimension + 1} dimensions were requested`,
|
|
621
|
+
);
|
|
622
|
+
} finally {
|
|
623
|
+
infoSpy.mockRestore();
|
|
624
|
+
warnSpy.mockRestore();
|
|
625
|
+
// Cleanup
|
|
626
|
+
await vectorDB.deleteIndex(duplicateIndexName);
|
|
627
|
+
}
|
|
628
|
+
});
|
|
567
629
|
});
|
|
568
630
|
|
|
569
631
|
describe('Performance Tests', () => {
|
package/src/vector/index.ts
CHANGED
|
@@ -61,6 +61,10 @@ export class PineconeVector extends MastraVector {
|
|
|
61
61
|
}) ?? baseClient;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
get indexSeparator(): string {
|
|
65
|
+
return '-';
|
|
66
|
+
}
|
|
67
|
+
|
|
64
68
|
async createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void> {
|
|
65
69
|
const params = this.normalizeArgs<CreateIndexParams>('createIndex', args);
|
|
66
70
|
|
|
@@ -69,17 +73,36 @@ export class PineconeVector extends MastraVector {
|
|
|
69
73
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
70
74
|
throw new Error('Dimension must be a positive integer');
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {
|
|
77
|
+
throw new Error('Metric must be one of: cosine, euclidean, dotproduct');
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
await this.client.createIndex({
|
|
81
|
+
name: indexName,
|
|
82
|
+
dimension: dimension,
|
|
83
|
+
metric: metric,
|
|
84
|
+
spec: {
|
|
85
|
+
serverless: {
|
|
86
|
+
cloud: 'aws',
|
|
87
|
+
region: 'us-east-1',
|
|
88
|
+
},
|
|
80
89
|
},
|
|
81
|
-
}
|
|
82
|
-
})
|
|
90
|
+
});
|
|
91
|
+
} catch (error: any) {
|
|
92
|
+
// Check for 'already exists' error
|
|
93
|
+
const message = error?.errors?.[0]?.message || error?.message;
|
|
94
|
+
if (
|
|
95
|
+
error.status === 409 ||
|
|
96
|
+
(typeof message === 'string' &&
|
|
97
|
+
(message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))
|
|
98
|
+
) {
|
|
99
|
+
// Fetch index info and check dimensions
|
|
100
|
+
await this.validateExistingIndex(indexName, dimension, metric);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
// For any other errors, propagate
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
83
106
|
}
|
|
84
107
|
|
|
85
108
|
async upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]> {
|