@mastra/pinecone 0.2.13-alpha.4 → 0.2.14-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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +35 -0
- package/dist/_tsup-dts-rollup.d.cts +41 -7
- package/dist/_tsup-dts-rollup.d.ts +41 -7
- package/dist/index.cjs +45 -9
- package/dist/index.js +45 -9
- package/package.json +3 -3
- package/src/vector/index.test.ts +49 -38
- package/src/vector/index.ts +71 -20
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/pinecone@0.2.
|
|
2
|
+
> @mastra/pinecone@0.2.14-alpha.0 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 6087ms
|
|
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 8467ms
|
|
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[32m15.44 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 493ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m15.38 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 494ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @mastra/pinecone
|
|
2
2
|
|
|
3
|
+
## 0.2.14-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
8
|
+
- Updated dependencies [f53a6ac]
|
|
9
|
+
- Updated dependencies [eabdcd9]
|
|
10
|
+
- Updated dependencies [90be034]
|
|
11
|
+
- Updated dependencies [99f050a]
|
|
12
|
+
- Updated dependencies [d0ee3c6]
|
|
13
|
+
- Updated dependencies [23f258c]
|
|
14
|
+
- Updated dependencies [2672a05]
|
|
15
|
+
- @mastra/core@0.9.5-alpha.0
|
|
16
|
+
|
|
17
|
+
## 0.2.13
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
22
|
+
- Updated dependencies [396be50]
|
|
23
|
+
- Updated dependencies [ab80e7e]
|
|
24
|
+
- Updated dependencies [c3bd795]
|
|
25
|
+
- Updated dependencies [da082f8]
|
|
26
|
+
- Updated dependencies [a5810ce]
|
|
27
|
+
- Updated dependencies [3e9c131]
|
|
28
|
+
- Updated dependencies [3171b5b]
|
|
29
|
+
- Updated dependencies [973e5ac]
|
|
30
|
+
- Updated dependencies [daf942f]
|
|
31
|
+
- Updated dependencies [0b8b868]
|
|
32
|
+
- Updated dependencies [9e1eff5]
|
|
33
|
+
- Updated dependencies [6fa1ad1]
|
|
34
|
+
- Updated dependencies [c28d7a0]
|
|
35
|
+
- Updated dependencies [edf1e88]
|
|
36
|
+
- @mastra/core@0.9.4
|
|
37
|
+
|
|
3
38
|
## 0.2.13-alpha.4
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorArgs } from '@mastra/core/vector';
|
|
5
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
6
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
3
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
4
8
|
import type { IndexStatsDescription } from '@pinecone-database/pinecone';
|
|
5
9
|
import { MastraVector } from '@mastra/core/vector';
|
|
@@ -9,6 +13,8 @@ import type { QueryResult } from '@mastra/core/vector';
|
|
|
9
13
|
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
10
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
11
15
|
import type { RecordSparseValues } from '@pinecone-database/pinecone';
|
|
16
|
+
import type { UpdateVectorArgs } from '@mastra/core/vector';
|
|
17
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
12
18
|
import type { UpsertVectorArgs } from '@mastra/core/vector';
|
|
13
19
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
14
20
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
@@ -21,6 +27,12 @@ declare const PINECONE_PROMPT = "When querying Pinecone, you can ONLY use the op
|
|
|
21
27
|
export { PINECONE_PROMPT }
|
|
22
28
|
export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
|
|
23
29
|
|
|
30
|
+
declare type PineconeDeleteVectorArgs = [...DeleteVectorArgs, string?];
|
|
31
|
+
|
|
32
|
+
declare interface PineconeDeleteVectorParams extends DeleteVectorParams {
|
|
33
|
+
namespace?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
export declare class PineconeFilterTranslator extends BaseFilterTranslator {
|
|
25
37
|
protected getSupportedOperators(): OperatorSupport;
|
|
26
38
|
translate(filter?: VectorFilter): VectorFilter;
|
|
@@ -39,6 +51,12 @@ declare interface PineconeQueryVectorParams extends QueryVectorParams {
|
|
|
39
51
|
sparseVector?: RecordSparseValues;
|
|
40
52
|
}
|
|
41
53
|
|
|
54
|
+
declare type PineconeUpdateVectorArgs = [...UpdateVectorArgs, string?];
|
|
55
|
+
|
|
56
|
+
declare interface PineconeUpdateVectorParams extends UpdateVectorParams {
|
|
57
|
+
namespace?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
42
60
|
declare type PineconeUpsertVectorArgs = [...UpsertVectorArgs, string?, RecordSparseValues[]?];
|
|
43
61
|
|
|
44
62
|
declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
@@ -48,15 +66,34 @@ declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
|
48
66
|
|
|
49
67
|
declare class PineconeVector extends MastraVector {
|
|
50
68
|
private client;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Passing apiKey and environment as positional arguments is deprecated.
|
|
71
|
+
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
72
|
+
*/
|
|
51
73
|
constructor(apiKey: string, environment?: string);
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new PineconeVector client.
|
|
76
|
+
* @param params - An object with apiKey and optional environment.
|
|
77
|
+
*/
|
|
78
|
+
constructor(params: {
|
|
79
|
+
apiKey: string;
|
|
80
|
+
environment?: string;
|
|
81
|
+
});
|
|
52
82
|
get indexSeparator(): string;
|
|
53
83
|
createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
54
84
|
upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]>;
|
|
55
85
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
56
86
|
query(...args: ParamsToArgs<PineconeQueryVectorParams> | PineconeQueryVectorArgs): Promise<QueryResult[]>;
|
|
57
87
|
listIndexes(): Promise<string[]>;
|
|
58
|
-
|
|
59
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves statistics about a vector index.
|
|
90
|
+
*
|
|
91
|
+
* @param params - The parameters for describing an index
|
|
92
|
+
* @param params.indexName - The name of the index to describe
|
|
93
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
94
|
+
*/
|
|
95
|
+
describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<PineconeIndexStats>;
|
|
96
|
+
deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
|
|
60
97
|
/**
|
|
61
98
|
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
62
99
|
*
|
|
@@ -85,10 +122,7 @@ declare class PineconeVector extends MastraVector {
|
|
|
85
122
|
* @returns A promise that resolves when the update is complete.
|
|
86
123
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
87
124
|
*/
|
|
88
|
-
updateVector(
|
|
89
|
-
vector?: number[];
|
|
90
|
-
metadata?: Record<string, any>;
|
|
91
|
-
}, namespace?: string): Promise<void>;
|
|
125
|
+
updateVector(...args: ParamsToArgs<PineconeUpdateVectorParams> | PineconeUpdateVectorArgs): Promise<void>;
|
|
92
126
|
/**
|
|
93
127
|
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
94
128
|
*
|
|
@@ -108,7 +142,7 @@ declare class PineconeVector extends MastraVector {
|
|
|
108
142
|
* @returns A promise that resolves when the deletion is complete.
|
|
109
143
|
* @throws Will throw an error if the deletion operation fails.
|
|
110
144
|
*/
|
|
111
|
-
deleteVector(
|
|
145
|
+
deleteVector(...args: ParamsToArgs<PineconeDeleteVectorParams> | PineconeDeleteVectorArgs): Promise<void>;
|
|
112
146
|
}
|
|
113
147
|
export { PineconeVector }
|
|
114
148
|
export { PineconeVector as PineconeVector_alias_1 }
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorArgs } from '@mastra/core/vector';
|
|
5
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
6
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
3
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
4
8
|
import type { IndexStatsDescription } from '@pinecone-database/pinecone';
|
|
5
9
|
import { MastraVector } from '@mastra/core/vector';
|
|
@@ -9,6 +13,8 @@ import type { QueryResult } from '@mastra/core/vector';
|
|
|
9
13
|
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
10
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
11
15
|
import type { RecordSparseValues } from '@pinecone-database/pinecone';
|
|
16
|
+
import type { UpdateVectorArgs } from '@mastra/core/vector';
|
|
17
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
12
18
|
import type { UpsertVectorArgs } from '@mastra/core/vector';
|
|
13
19
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
14
20
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
@@ -21,6 +27,12 @@ declare const PINECONE_PROMPT = "When querying Pinecone, you can ONLY use the op
|
|
|
21
27
|
export { PINECONE_PROMPT }
|
|
22
28
|
export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
|
|
23
29
|
|
|
30
|
+
declare type PineconeDeleteVectorArgs = [...DeleteVectorArgs, string?];
|
|
31
|
+
|
|
32
|
+
declare interface PineconeDeleteVectorParams extends DeleteVectorParams {
|
|
33
|
+
namespace?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
export declare class PineconeFilterTranslator extends BaseFilterTranslator {
|
|
25
37
|
protected getSupportedOperators(): OperatorSupport;
|
|
26
38
|
translate(filter?: VectorFilter): VectorFilter;
|
|
@@ -39,6 +51,12 @@ declare interface PineconeQueryVectorParams extends QueryVectorParams {
|
|
|
39
51
|
sparseVector?: RecordSparseValues;
|
|
40
52
|
}
|
|
41
53
|
|
|
54
|
+
declare type PineconeUpdateVectorArgs = [...UpdateVectorArgs, string?];
|
|
55
|
+
|
|
56
|
+
declare interface PineconeUpdateVectorParams extends UpdateVectorParams {
|
|
57
|
+
namespace?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
42
60
|
declare type PineconeUpsertVectorArgs = [...UpsertVectorArgs, string?, RecordSparseValues[]?];
|
|
43
61
|
|
|
44
62
|
declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
@@ -48,15 +66,34 @@ declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
|
48
66
|
|
|
49
67
|
declare class PineconeVector extends MastraVector {
|
|
50
68
|
private client;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Passing apiKey and environment as positional arguments is deprecated.
|
|
71
|
+
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
72
|
+
*/
|
|
51
73
|
constructor(apiKey: string, environment?: string);
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new PineconeVector client.
|
|
76
|
+
* @param params - An object with apiKey and optional environment.
|
|
77
|
+
*/
|
|
78
|
+
constructor(params: {
|
|
79
|
+
apiKey: string;
|
|
80
|
+
environment?: string;
|
|
81
|
+
});
|
|
52
82
|
get indexSeparator(): string;
|
|
53
83
|
createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
54
84
|
upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]>;
|
|
55
85
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
56
86
|
query(...args: ParamsToArgs<PineconeQueryVectorParams> | PineconeQueryVectorArgs): Promise<QueryResult[]>;
|
|
57
87
|
listIndexes(): Promise<string[]>;
|
|
58
|
-
|
|
59
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves statistics about a vector index.
|
|
90
|
+
*
|
|
91
|
+
* @param params - The parameters for describing an index
|
|
92
|
+
* @param params.indexName - The name of the index to describe
|
|
93
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
94
|
+
*/
|
|
95
|
+
describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<PineconeIndexStats>;
|
|
96
|
+
deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
|
|
60
97
|
/**
|
|
61
98
|
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
62
99
|
*
|
|
@@ -85,10 +122,7 @@ declare class PineconeVector extends MastraVector {
|
|
|
85
122
|
* @returns A promise that resolves when the update is complete.
|
|
86
123
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
87
124
|
*/
|
|
88
|
-
updateVector(
|
|
89
|
-
vector?: number[];
|
|
90
|
-
metadata?: Record<string, any>;
|
|
91
|
-
}, namespace?: string): Promise<void>;
|
|
125
|
+
updateVector(...args: ParamsToArgs<PineconeUpdateVectorParams> | PineconeUpdateVectorArgs): Promise<void>;
|
|
92
126
|
/**
|
|
93
127
|
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
94
128
|
*
|
|
@@ -108,7 +142,7 @@ declare class PineconeVector extends MastraVector {
|
|
|
108
142
|
* @returns A promise that resolves when the deletion is complete.
|
|
109
143
|
* @throws Will throw an error if the deletion operation fails.
|
|
110
144
|
*/
|
|
111
|
-
deleteVector(
|
|
145
|
+
deleteVector(...args: ParamsToArgs<PineconeDeleteVectorParams> | PineconeDeleteVectorArgs): Promise<void>;
|
|
112
146
|
}
|
|
113
147
|
export { PineconeVector }
|
|
114
148
|
export { PineconeVector as PineconeVector_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -85,11 +85,28 @@ var PineconeFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
|
85
85
|
// src/vector/index.ts
|
|
86
86
|
var PineconeVector = class extends vector.MastraVector {
|
|
87
87
|
client;
|
|
88
|
-
constructor(
|
|
88
|
+
constructor(paramsOrApiKey, environment) {
|
|
89
89
|
super();
|
|
90
|
+
let apiKey;
|
|
91
|
+
let env;
|
|
92
|
+
if (typeof paramsOrApiKey === "string") {
|
|
93
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
94
|
+
console.warn(
|
|
95
|
+
`Deprecation Warning: Passing apiKey and environment as positional arguments to PineconeVector constructor is deprecated.
|
|
96
|
+
Please use an object parameter instead:
|
|
97
|
+
new PineconeVector({ apiKey, environment })
|
|
98
|
+
This signature will be removed on May 20th, 2025.`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
apiKey = paramsOrApiKey;
|
|
102
|
+
env = environment;
|
|
103
|
+
} else {
|
|
104
|
+
apiKey = paramsOrApiKey.apiKey;
|
|
105
|
+
env = paramsOrApiKey.environment;
|
|
106
|
+
}
|
|
90
107
|
const opts = { apiKey };
|
|
91
|
-
if (
|
|
92
|
-
opts["controllerHostUrl"] =
|
|
108
|
+
if (env) {
|
|
109
|
+
opts["controllerHostUrl"] = env;
|
|
93
110
|
}
|
|
94
111
|
const baseClient = new pinecone.Pinecone(opts);
|
|
95
112
|
const telemetry = this.__getTelemetry();
|
|
@@ -188,7 +205,16 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
188
205
|
const indexesResult = await this.client.listIndexes();
|
|
189
206
|
return indexesResult?.indexes?.map((index) => index.name) || [];
|
|
190
207
|
}
|
|
191
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Retrieves statistics about a vector index.
|
|
210
|
+
*
|
|
211
|
+
* @param params - The parameters for describing an index
|
|
212
|
+
* @param params.indexName - The name of the index to describe
|
|
213
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
214
|
+
*/
|
|
215
|
+
async describeIndex(...args) {
|
|
216
|
+
const params = this.normalizeArgs("describeIndex", args);
|
|
217
|
+
const { indexName } = params;
|
|
192
218
|
const index = this.client.Index(indexName);
|
|
193
219
|
const stats = await index.describeIndexStats();
|
|
194
220
|
const description = await this.client.describeIndex(indexName);
|
|
@@ -199,7 +225,9 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
199
225
|
namespaces: stats.namespaces
|
|
200
226
|
};
|
|
201
227
|
}
|
|
202
|
-
async deleteIndex(
|
|
228
|
+
async deleteIndex(...args) {
|
|
229
|
+
const params = this.normalizeArgs("deleteIndex", args);
|
|
230
|
+
const { indexName } = params;
|
|
203
231
|
try {
|
|
204
232
|
await this.client.deleteIndex(indexName);
|
|
205
233
|
} catch (error) {
|
|
@@ -225,7 +253,7 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
225
253
|
Please use updateVector() instead.
|
|
226
254
|
updateIndexById() will be removed on May 20th, 2025.`
|
|
227
255
|
);
|
|
228
|
-
await this.updateVector(indexName, id, update, namespace);
|
|
256
|
+
await this.updateVector({ indexName, id, update, namespace });
|
|
229
257
|
}
|
|
230
258
|
/**
|
|
231
259
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
@@ -238,7 +266,11 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
238
266
|
* @returns A promise that resolves when the update is complete.
|
|
239
267
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
240
268
|
*/
|
|
241
|
-
async updateVector(
|
|
269
|
+
async updateVector(...args) {
|
|
270
|
+
const params = this.normalizeArgs("updateVector", args, [
|
|
271
|
+
"namespace"
|
|
272
|
+
]);
|
|
273
|
+
const { indexName, id, update, namespace } = params;
|
|
242
274
|
try {
|
|
243
275
|
if (!update.vector && !update.metadata) {
|
|
244
276
|
throw new Error("No updates provided");
|
|
@@ -272,7 +304,7 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
272
304
|
Please use deleteVector() instead.
|
|
273
305
|
deleteIndexById() will be removed on May 20th, 2025.`
|
|
274
306
|
);
|
|
275
|
-
await this.deleteVector(indexName, id, namespace);
|
|
307
|
+
await this.deleteVector({ indexName, id, namespace });
|
|
276
308
|
}
|
|
277
309
|
/**
|
|
278
310
|
* Deletes a vector by its ID.
|
|
@@ -282,7 +314,11 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
282
314
|
* @returns A promise that resolves when the deletion is complete.
|
|
283
315
|
* @throws Will throw an error if the deletion operation fails.
|
|
284
316
|
*/
|
|
285
|
-
async deleteVector(
|
|
317
|
+
async deleteVector(...args) {
|
|
318
|
+
const params = this.normalizeArgs("deleteVector", args, [
|
|
319
|
+
"namespace"
|
|
320
|
+
]);
|
|
321
|
+
const { indexName, id, namespace } = params;
|
|
286
322
|
try {
|
|
287
323
|
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
288
324
|
await index.deleteOne(id);
|
package/dist/index.js
CHANGED
|
@@ -83,11 +83,28 @@ var PineconeFilterTranslator = class extends BaseFilterTranslator {
|
|
|
83
83
|
// src/vector/index.ts
|
|
84
84
|
var PineconeVector = class extends MastraVector {
|
|
85
85
|
client;
|
|
86
|
-
constructor(
|
|
86
|
+
constructor(paramsOrApiKey, environment) {
|
|
87
87
|
super();
|
|
88
|
+
let apiKey;
|
|
89
|
+
let env;
|
|
90
|
+
if (typeof paramsOrApiKey === "string") {
|
|
91
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
92
|
+
console.warn(
|
|
93
|
+
`Deprecation Warning: Passing apiKey and environment as positional arguments to PineconeVector constructor is deprecated.
|
|
94
|
+
Please use an object parameter instead:
|
|
95
|
+
new PineconeVector({ apiKey, environment })
|
|
96
|
+
This signature will be removed on May 20th, 2025.`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
apiKey = paramsOrApiKey;
|
|
100
|
+
env = environment;
|
|
101
|
+
} else {
|
|
102
|
+
apiKey = paramsOrApiKey.apiKey;
|
|
103
|
+
env = paramsOrApiKey.environment;
|
|
104
|
+
}
|
|
88
105
|
const opts = { apiKey };
|
|
89
|
-
if (
|
|
90
|
-
opts["controllerHostUrl"] =
|
|
106
|
+
if (env) {
|
|
107
|
+
opts["controllerHostUrl"] = env;
|
|
91
108
|
}
|
|
92
109
|
const baseClient = new Pinecone(opts);
|
|
93
110
|
const telemetry = this.__getTelemetry();
|
|
@@ -186,7 +203,16 @@ var PineconeVector = class extends MastraVector {
|
|
|
186
203
|
const indexesResult = await this.client.listIndexes();
|
|
187
204
|
return indexesResult?.indexes?.map((index) => index.name) || [];
|
|
188
205
|
}
|
|
189
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Retrieves statistics about a vector index.
|
|
208
|
+
*
|
|
209
|
+
* @param params - The parameters for describing an index
|
|
210
|
+
* @param params.indexName - The name of the index to describe
|
|
211
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
212
|
+
*/
|
|
213
|
+
async describeIndex(...args) {
|
|
214
|
+
const params = this.normalizeArgs("describeIndex", args);
|
|
215
|
+
const { indexName } = params;
|
|
190
216
|
const index = this.client.Index(indexName);
|
|
191
217
|
const stats = await index.describeIndexStats();
|
|
192
218
|
const description = await this.client.describeIndex(indexName);
|
|
@@ -197,7 +223,9 @@ var PineconeVector = class extends MastraVector {
|
|
|
197
223
|
namespaces: stats.namespaces
|
|
198
224
|
};
|
|
199
225
|
}
|
|
200
|
-
async deleteIndex(
|
|
226
|
+
async deleteIndex(...args) {
|
|
227
|
+
const params = this.normalizeArgs("deleteIndex", args);
|
|
228
|
+
const { indexName } = params;
|
|
201
229
|
try {
|
|
202
230
|
await this.client.deleteIndex(indexName);
|
|
203
231
|
} catch (error) {
|
|
@@ -223,7 +251,7 @@ var PineconeVector = class extends MastraVector {
|
|
|
223
251
|
Please use updateVector() instead.
|
|
224
252
|
updateIndexById() will be removed on May 20th, 2025.`
|
|
225
253
|
);
|
|
226
|
-
await this.updateVector(indexName, id, update, namespace);
|
|
254
|
+
await this.updateVector({ indexName, id, update, namespace });
|
|
227
255
|
}
|
|
228
256
|
/**
|
|
229
257
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
@@ -236,7 +264,11 @@ var PineconeVector = class extends MastraVector {
|
|
|
236
264
|
* @returns A promise that resolves when the update is complete.
|
|
237
265
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
238
266
|
*/
|
|
239
|
-
async updateVector(
|
|
267
|
+
async updateVector(...args) {
|
|
268
|
+
const params = this.normalizeArgs("updateVector", args, [
|
|
269
|
+
"namespace"
|
|
270
|
+
]);
|
|
271
|
+
const { indexName, id, update, namespace } = params;
|
|
240
272
|
try {
|
|
241
273
|
if (!update.vector && !update.metadata) {
|
|
242
274
|
throw new Error("No updates provided");
|
|
@@ -270,7 +302,7 @@ var PineconeVector = class extends MastraVector {
|
|
|
270
302
|
Please use deleteVector() instead.
|
|
271
303
|
deleteIndexById() will be removed on May 20th, 2025.`
|
|
272
304
|
);
|
|
273
|
-
await this.deleteVector(indexName, id, namespace);
|
|
305
|
+
await this.deleteVector({ indexName, id, namespace });
|
|
274
306
|
}
|
|
275
307
|
/**
|
|
276
308
|
* Deletes a vector by its ID.
|
|
@@ -280,7 +312,11 @@ var PineconeVector = class extends MastraVector {
|
|
|
280
312
|
* @returns A promise that resolves when the deletion is complete.
|
|
281
313
|
* @throws Will throw an error if the deletion operation fails.
|
|
282
314
|
*/
|
|
283
|
-
async deleteVector(
|
|
315
|
+
async deleteVector(...args) {
|
|
316
|
+
const params = this.normalizeArgs("deleteVector", args, [
|
|
317
|
+
"namespace"
|
|
318
|
+
]);
|
|
319
|
+
const { indexName, id, namespace } = params;
|
|
284
320
|
try {
|
|
285
321
|
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
286
322
|
await index.deleteOne(id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pinecone",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14-alpha.0",
|
|
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.
|
|
24
|
+
"@mastra/core": "^0.9.5-alpha.0"
|
|
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.5"
|
|
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
|
@@ -36,7 +36,7 @@ function waitUntilReady(vectorDB: PineconeVector, indexName: string) {
|
|
|
36
36
|
return new Promise(resolve => {
|
|
37
37
|
const interval = setInterval(async () => {
|
|
38
38
|
try {
|
|
39
|
-
const stats = await vectorDB.describeIndex(indexName);
|
|
39
|
+
const stats = await vectorDB.describeIndex({ indexName });
|
|
40
40
|
if (!!stats) {
|
|
41
41
|
clearInterval(interval);
|
|
42
42
|
resolve(true);
|
|
@@ -86,7 +86,7 @@ function waitUntilVectorsIndexed(
|
|
|
86
86
|
|
|
87
87
|
const interval = setInterval(async () => {
|
|
88
88
|
try {
|
|
89
|
-
const stats = await vectorDB.describeIndex(indexName);
|
|
89
|
+
const stats = await vectorDB.describeIndex({ indexName });
|
|
90
90
|
const check = exactCount ? stats?.count === expectedCount : stats?.count >= expectedCount;
|
|
91
91
|
if (stats && check) {
|
|
92
92
|
if (stats.count === lastCount) {
|
|
@@ -122,34 +122,36 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
122
122
|
const dimension = 3;
|
|
123
123
|
|
|
124
124
|
beforeAll(async () => {
|
|
125
|
-
vectorDB = new PineconeVector(
|
|
125
|
+
vectorDB = new PineconeVector({
|
|
126
|
+
apiKey: PINECONE_API_KEY,
|
|
127
|
+
});
|
|
126
128
|
// Delete test index
|
|
127
129
|
try {
|
|
128
|
-
await vectorDB.deleteIndex(testIndexName);
|
|
130
|
+
await vectorDB.deleteIndex({ indexName: testIndexName });
|
|
129
131
|
await waitUntilIndexDeleted(vectorDB, testIndexName);
|
|
130
132
|
} catch {
|
|
131
133
|
// Ignore errors if index doesn't exist
|
|
132
134
|
}
|
|
133
135
|
try {
|
|
134
|
-
await vectorDB.deleteIndex(indexNameUpdate);
|
|
136
|
+
await vectorDB.deleteIndex({ indexName: indexNameUpdate });
|
|
135
137
|
await waitUntilIndexDeleted(vectorDB, indexNameUpdate);
|
|
136
138
|
} catch {
|
|
137
139
|
// Ignore errors if index doesn't exist
|
|
138
140
|
}
|
|
139
141
|
try {
|
|
140
|
-
await vectorDB.deleteIndex(indexNameDelete);
|
|
142
|
+
await vectorDB.deleteIndex({ indexName: indexNameDelete });
|
|
141
143
|
await waitUntilIndexDeleted(vectorDB, indexNameDelete);
|
|
142
144
|
} catch {
|
|
143
145
|
// Ignore errors if index doesn't exist
|
|
144
146
|
}
|
|
145
147
|
try {
|
|
146
|
-
await vectorDB.deleteIndex(indexNameNamespace);
|
|
148
|
+
await vectorDB.deleteIndex({ indexName: indexNameNamespace });
|
|
147
149
|
await waitUntilIndexDeleted(vectorDB, indexNameNamespace);
|
|
148
150
|
} catch {
|
|
149
151
|
// Ignore errors if index doesn't exist
|
|
150
152
|
}
|
|
151
153
|
try {
|
|
152
|
-
await vectorDB.deleteIndex(indexNameHybrid);
|
|
154
|
+
await vectorDB.deleteIndex({ indexName: indexNameHybrid });
|
|
153
155
|
await waitUntilIndexDeleted(vectorDB, indexNameHybrid);
|
|
154
156
|
} catch {
|
|
155
157
|
// Ignore errors if index doesn't exist
|
|
@@ -162,27 +164,27 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
162
164
|
afterAll(async () => {
|
|
163
165
|
// Cleanup: delete test index
|
|
164
166
|
try {
|
|
165
|
-
await vectorDB.deleteIndex(testIndexName);
|
|
167
|
+
await vectorDB.deleteIndex({ indexName: testIndexName });
|
|
166
168
|
} catch {
|
|
167
169
|
// Ignore errors if index doesn't exist
|
|
168
170
|
}
|
|
169
171
|
try {
|
|
170
|
-
await vectorDB.deleteIndex(indexNameUpdate);
|
|
172
|
+
await vectorDB.deleteIndex({ indexName: indexNameUpdate });
|
|
171
173
|
} catch {
|
|
172
174
|
// Ignore errors if index doesn't exist
|
|
173
175
|
}
|
|
174
176
|
try {
|
|
175
|
-
await vectorDB.deleteIndex(indexNameDelete);
|
|
177
|
+
await vectorDB.deleteIndex({ indexName: indexNameDelete });
|
|
176
178
|
} catch {
|
|
177
179
|
// Ignore errors if index doesn't exist
|
|
178
180
|
}
|
|
179
181
|
try {
|
|
180
|
-
await vectorDB.deleteIndex(indexNameNamespace);
|
|
182
|
+
await vectorDB.deleteIndex({ indexName: indexNameNamespace });
|
|
181
183
|
} catch {
|
|
182
184
|
// Ignore errors if index doesn't exist
|
|
183
185
|
}
|
|
184
186
|
try {
|
|
185
|
-
await vectorDB.deleteIndex(indexNameHybrid);
|
|
187
|
+
await vectorDB.deleteIndex({ indexName: indexNameHybrid });
|
|
186
188
|
} catch {
|
|
187
189
|
// Ignore errors if index doesn't exist
|
|
188
190
|
}
|
|
@@ -195,7 +197,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
195
197
|
}, 500000);
|
|
196
198
|
|
|
197
199
|
it('should describe index with correct properties', async () => {
|
|
198
|
-
const stats = await vectorDB.describeIndex(testIndexName);
|
|
200
|
+
const stats = await vectorDB.describeIndex({ indexName: testIndexName });
|
|
199
201
|
expect(stats.dimension).toBe(dimension);
|
|
200
202
|
expect(stats.metric).toBe('cosine');
|
|
201
203
|
expect(typeof stats.count).toBe('number');
|
|
@@ -260,7 +262,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
260
262
|
|
|
261
263
|
afterEach(async () => {
|
|
262
264
|
try {
|
|
263
|
-
await vectorDB.deleteIndex(indexNameUpdate);
|
|
265
|
+
await vectorDB.deleteIndex({ indexName: indexNameUpdate });
|
|
264
266
|
await waitUntilIndexDeleted(vectorDB, indexNameUpdate);
|
|
265
267
|
} catch {
|
|
266
268
|
// Ignore errors if index doesn't exist
|
|
@@ -282,7 +284,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
282
284
|
metadata: newMetaData,
|
|
283
285
|
};
|
|
284
286
|
|
|
285
|
-
await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
|
|
287
|
+
await vectorDB.updateVector({ indexName: indexNameUpdate, id: idToBeUpdated, update });
|
|
286
288
|
|
|
287
289
|
await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
|
|
288
290
|
|
|
@@ -311,7 +313,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
311
313
|
metadata: newMetaData,
|
|
312
314
|
};
|
|
313
315
|
|
|
314
|
-
await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
|
|
316
|
+
await vectorDB.updateVector({ indexName: indexNameUpdate, id: idToBeUpdated, update });
|
|
315
317
|
|
|
316
318
|
await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
|
|
317
319
|
|
|
@@ -338,7 +340,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
338
340
|
vector: newVector,
|
|
339
341
|
};
|
|
340
342
|
|
|
341
|
-
await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
|
|
343
|
+
await vectorDB.updateVector({ indexName: indexNameUpdate, id: idToBeUpdated, update });
|
|
342
344
|
|
|
343
345
|
await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
|
|
344
346
|
|
|
@@ -355,12 +357,16 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
355
357
|
}, 500000);
|
|
356
358
|
|
|
357
359
|
it('should throw exception when no updates are given', async () => {
|
|
358
|
-
await expect(vectorDB.updateVector(indexNameUpdate, 'id', {})).rejects.toThrow(
|
|
360
|
+
await expect(vectorDB.updateVector({ indexName: indexNameUpdate, id: 'id', update: {} })).rejects.toThrow(
|
|
361
|
+
'No updates provided',
|
|
362
|
+
);
|
|
359
363
|
});
|
|
360
364
|
|
|
361
365
|
it('should throw error for non-existent index', async () => {
|
|
362
366
|
const nonExistentIndex = 'non-existent-index';
|
|
363
|
-
await expect(
|
|
367
|
+
await expect(
|
|
368
|
+
vectorDB.updateVector({ indexName: nonExistentIndex, id: 'test-id', update: { vector: [1, 2, 3] } }),
|
|
369
|
+
).rejects.toThrow();
|
|
364
370
|
});
|
|
365
371
|
|
|
366
372
|
it('should throw error for invalid vector dimension', async () => {
|
|
@@ -371,7 +377,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
371
377
|
});
|
|
372
378
|
|
|
373
379
|
await expect(
|
|
374
|
-
vectorDB.updateVector(indexNameUpdate, id, { vector: [1, 2] }), // Wrong dimension
|
|
380
|
+
vectorDB.updateVector({ indexName: indexNameUpdate, id, update: { vector: [1, 2] } }), // Wrong dimension
|
|
375
381
|
).rejects.toThrow();
|
|
376
382
|
}, 500000);
|
|
377
383
|
});
|
|
@@ -390,7 +396,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
390
396
|
|
|
391
397
|
afterEach(async () => {
|
|
392
398
|
try {
|
|
393
|
-
await vectorDB.deleteIndex(indexNameDelete);
|
|
399
|
+
await vectorDB.deleteIndex({ indexName: indexNameDelete });
|
|
394
400
|
await waitUntilIndexDeleted(vectorDB, indexNameDelete);
|
|
395
401
|
} catch {
|
|
396
402
|
// Ignore errors if index doesn't exist
|
|
@@ -402,7 +408,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
402
408
|
expect(ids).toHaveLength(3);
|
|
403
409
|
const idToBeDeleted = ids[0];
|
|
404
410
|
|
|
405
|
-
await vectorDB.deleteVector(indexNameDelete, idToBeDeleted);
|
|
411
|
+
await vectorDB.deleteVector({ indexName: indexNameDelete, id: idToBeDeleted });
|
|
406
412
|
await waitUntilVectorsIndexed(vectorDB, indexNameDelete, 2, true);
|
|
407
413
|
|
|
408
414
|
// Query all vectors similar to the deleted one
|
|
@@ -432,7 +438,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
432
438
|
|
|
433
439
|
afterEach(async () => {
|
|
434
440
|
try {
|
|
435
|
-
await vectorDB.deleteIndex(indexNameNamespace);
|
|
441
|
+
await vectorDB.deleteIndex({ indexName: indexNameNamespace });
|
|
436
442
|
await waitUntilIndexDeleted(vectorDB, indexNameNamespace);
|
|
437
443
|
} catch {
|
|
438
444
|
// Ignore errors if index doesn't exist
|
|
@@ -490,7 +496,12 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
490
496
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
|
|
491
497
|
|
|
492
498
|
// Update in namespace1
|
|
493
|
-
await vectorDB.updateVector(
|
|
499
|
+
await vectorDB.updateVector({
|
|
500
|
+
indexName: indexNameNamespace,
|
|
501
|
+
id,
|
|
502
|
+
update: { metadata: { label: 'updated' } },
|
|
503
|
+
namespace: namespace1,
|
|
504
|
+
});
|
|
494
505
|
|
|
495
506
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
|
|
496
507
|
|
|
@@ -515,7 +526,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
515
526
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
|
|
516
527
|
|
|
517
528
|
// Delete from namespace1
|
|
518
|
-
await vectorDB.deleteVector(indexNameNamespace, id, namespace1);
|
|
529
|
+
await vectorDB.deleteVector({ indexName: indexNameNamespace, id, namespace: namespace1 });
|
|
519
530
|
|
|
520
531
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 0, true);
|
|
521
532
|
|
|
@@ -545,7 +556,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
545
556
|
});
|
|
546
557
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 2);
|
|
547
558
|
|
|
548
|
-
const stats = await vectorDB.describeIndex(indexNameNamespace);
|
|
559
|
+
const stats = await vectorDB.describeIndex({ indexName: indexNameNamespace });
|
|
549
560
|
expect(stats.namespaces).toBeDefined();
|
|
550
561
|
expect(stats.namespaces?.[namespace1]).toBeDefined();
|
|
551
562
|
expect(stats.namespaces?.[namespace2]).toBeDefined();
|
|
@@ -561,7 +572,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
561
572
|
});
|
|
562
573
|
|
|
563
574
|
afterAll(async () => {
|
|
564
|
-
await vectorDB.deleteIndex(testIndexName);
|
|
575
|
+
await vectorDB.deleteIndex({ indexName: testIndexName });
|
|
565
576
|
});
|
|
566
577
|
it('should handle non-existent index query gracefully', async () => {
|
|
567
578
|
const nonExistentIndex = 'non-existent-index';
|
|
@@ -623,7 +634,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
623
634
|
infoSpy.mockRestore();
|
|
624
635
|
warnSpy.mockRestore();
|
|
625
636
|
// Cleanup
|
|
626
|
-
await vectorDB.deleteIndex(duplicateIndexName);
|
|
637
|
+
await vectorDB.deleteIndex({ indexName: duplicateIndexName });
|
|
627
638
|
}
|
|
628
639
|
});
|
|
629
640
|
});
|
|
@@ -1402,7 +1413,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
1402
1413
|
|
|
1403
1414
|
afterEach(async () => {
|
|
1404
1415
|
try {
|
|
1405
|
-
await vectorDB.deleteIndex(indexNameHybrid);
|
|
1416
|
+
await vectorDB.deleteIndex({ indexName: indexNameHybrid });
|
|
1406
1417
|
await waitUntilIndexDeleted(vectorDB, indexNameHybrid);
|
|
1407
1418
|
} catch {
|
|
1408
1419
|
// Ignore errors if index doesn't exist
|
|
@@ -1481,22 +1492,22 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
1481
1492
|
|
|
1482
1493
|
beforeAll(async () => {
|
|
1483
1494
|
try {
|
|
1484
|
-
await vectorDB.deleteIndex(indexName);
|
|
1495
|
+
await vectorDB.deleteIndex({ indexName });
|
|
1485
1496
|
} catch {
|
|
1486
1497
|
// Ignore errors if index doesn't exist
|
|
1487
1498
|
}
|
|
1488
1499
|
try {
|
|
1489
|
-
await vectorDB.deleteIndex(indexName2);
|
|
1500
|
+
await vectorDB.deleteIndex({ indexName: indexName2 });
|
|
1490
1501
|
} catch {
|
|
1491
1502
|
// Ignore errors if index doesn't exist
|
|
1492
1503
|
}
|
|
1493
1504
|
try {
|
|
1494
|
-
await vectorDB.deleteIndex(indexName3);
|
|
1505
|
+
await vectorDB.deleteIndex({ indexName: indexName3 });
|
|
1495
1506
|
} catch {
|
|
1496
1507
|
// Ignore errors if index doesn't exist
|
|
1497
1508
|
}
|
|
1498
1509
|
try {
|
|
1499
|
-
await vectorDB.deleteIndex(indexName4);
|
|
1510
|
+
await vectorDB.deleteIndex({ indexName: indexName4 });
|
|
1500
1511
|
} catch {
|
|
1501
1512
|
// Ignore errors if index doesn't exist
|
|
1502
1513
|
}
|
|
@@ -1506,22 +1517,22 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
1506
1517
|
|
|
1507
1518
|
afterAll(async () => {
|
|
1508
1519
|
try {
|
|
1509
|
-
await vectorDB.deleteIndex(indexName);
|
|
1520
|
+
await vectorDB.deleteIndex({ indexName });
|
|
1510
1521
|
} catch {
|
|
1511
1522
|
// Ignore errors if index doesn't exist
|
|
1512
1523
|
}
|
|
1513
1524
|
try {
|
|
1514
|
-
await vectorDB.deleteIndex(indexName2);
|
|
1525
|
+
await vectorDB.deleteIndex({ indexName: indexName2 });
|
|
1515
1526
|
} catch {
|
|
1516
1527
|
// Ignore errors if index doesn't exist
|
|
1517
1528
|
}
|
|
1518
1529
|
try {
|
|
1519
|
-
await vectorDB.deleteIndex(indexName3);
|
|
1530
|
+
await vectorDB.deleteIndex({ indexName: indexName3 });
|
|
1520
1531
|
} catch {
|
|
1521
1532
|
// Ignore errors if index doesn't exist
|
|
1522
1533
|
}
|
|
1523
1534
|
try {
|
|
1524
|
-
await vectorDB.deleteIndex(indexName4);
|
|
1535
|
+
await vectorDB.deleteIndex({ indexName: indexName4 });
|
|
1525
1536
|
} catch {
|
|
1526
1537
|
// Ignore errors if index doesn't exist
|
|
1527
1538
|
}
|
package/src/vector/index.ts
CHANGED
|
@@ -8,6 +8,12 @@ import type {
|
|
|
8
8
|
ParamsToArgs,
|
|
9
9
|
QueryVectorArgs,
|
|
10
10
|
UpsertVectorArgs,
|
|
11
|
+
DescribeIndexParams,
|
|
12
|
+
DeleteIndexParams,
|
|
13
|
+
DeleteVectorParams,
|
|
14
|
+
DeleteVectorArgs,
|
|
15
|
+
UpdateVectorParams,
|
|
16
|
+
UpdateVectorArgs,
|
|
11
17
|
} from '@mastra/core/vector';
|
|
12
18
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
13
19
|
import { Pinecone } from '@pinecone-database/pinecone';
|
|
@@ -38,18 +44,52 @@ interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
|
38
44
|
|
|
39
45
|
type PineconeUpsertVectorArgs = [...UpsertVectorArgs, string?, RecordSparseValues[]?];
|
|
40
46
|
|
|
47
|
+
interface PineconeUpdateVectorParams extends UpdateVectorParams {
|
|
48
|
+
namespace?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type PineconeUpdateVectorArgs = [...UpdateVectorArgs, string?];
|
|
52
|
+
|
|
53
|
+
interface PineconeDeleteVectorParams extends DeleteVectorParams {
|
|
54
|
+
namespace?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type PineconeDeleteVectorArgs = [...DeleteVectorArgs, string?];
|
|
58
|
+
|
|
41
59
|
export class PineconeVector extends MastraVector {
|
|
42
60
|
private client: Pinecone;
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Passing apiKey and environment as positional arguments is deprecated.
|
|
64
|
+
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
65
|
+
*/
|
|
66
|
+
constructor(apiKey: string, environment?: string);
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new PineconeVector client.
|
|
69
|
+
* @param params - An object with apiKey and optional environment.
|
|
70
|
+
*/
|
|
71
|
+
constructor(params: { apiKey: string; environment?: string });
|
|
72
|
+
constructor(paramsOrApiKey: { apiKey: string; environment?: string } | string, environment?: string) {
|
|
45
73
|
super();
|
|
46
|
-
|
|
74
|
+
let apiKey: string;
|
|
75
|
+
let env: string | undefined;
|
|
76
|
+
if (typeof paramsOrApiKey === 'string') {
|
|
77
|
+
// DEPRECATION WARNING
|
|
78
|
+
if (typeof console !== 'undefined' && console.warn) {
|
|
79
|
+
console.warn(
|
|
80
|
+
`Deprecation Warning: Passing apiKey and environment as positional arguments to PineconeVector constructor is deprecated.\nPlease use an object parameter instead:\n new PineconeVector({ apiKey, environment })\nThis signature will be removed on May 20th, 2025.`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
apiKey = paramsOrApiKey;
|
|
84
|
+
env = environment;
|
|
85
|
+
} else {
|
|
86
|
+
apiKey = paramsOrApiKey.apiKey;
|
|
87
|
+
env = paramsOrApiKey.environment;
|
|
88
|
+
}
|
|
47
89
|
const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
opts['controllerHostUrl'] = environment;
|
|
90
|
+
if (env) {
|
|
91
|
+
opts['controllerHostUrl'] = env;
|
|
51
92
|
}
|
|
52
|
-
|
|
53
93
|
const baseClient = new Pinecone(opts);
|
|
54
94
|
const telemetry = this.__getTelemetry();
|
|
55
95
|
this.client =
|
|
@@ -180,7 +220,16 @@ export class PineconeVector extends MastraVector {
|
|
|
180
220
|
return indexesResult?.indexes?.map(index => index.name) || [];
|
|
181
221
|
}
|
|
182
222
|
|
|
183
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Retrieves statistics about a vector index.
|
|
225
|
+
*
|
|
226
|
+
* @param params - The parameters for describing an index
|
|
227
|
+
* @param params.indexName - The name of the index to describe
|
|
228
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
229
|
+
*/
|
|
230
|
+
async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<PineconeIndexStats> {
|
|
231
|
+
const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
|
|
232
|
+
const { indexName } = params;
|
|
184
233
|
const index = this.client.Index(indexName);
|
|
185
234
|
const stats = await index.describeIndexStats();
|
|
186
235
|
const description = await this.client.describeIndex(indexName);
|
|
@@ -193,7 +242,9 @@ export class PineconeVector extends MastraVector {
|
|
|
193
242
|
};
|
|
194
243
|
}
|
|
195
244
|
|
|
196
|
-
async deleteIndex(
|
|
245
|
+
async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
|
|
246
|
+
const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
|
|
247
|
+
const { indexName } = params;
|
|
197
248
|
try {
|
|
198
249
|
await this.client.deleteIndex(indexName);
|
|
199
250
|
} catch (error: any) {
|
|
@@ -224,7 +275,7 @@ export class PineconeVector extends MastraVector {
|
|
|
224
275
|
Please use updateVector() instead.
|
|
225
276
|
updateIndexById() will be removed on May 20th, 2025.`,
|
|
226
277
|
);
|
|
227
|
-
await this.updateVector(indexName, id, update, namespace);
|
|
278
|
+
await this.updateVector({ indexName, id, update, namespace });
|
|
228
279
|
}
|
|
229
280
|
|
|
230
281
|
/**
|
|
@@ -238,15 +289,11 @@ export class PineconeVector extends MastraVector {
|
|
|
238
289
|
* @returns A promise that resolves when the update is complete.
|
|
239
290
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
240
291
|
*/
|
|
241
|
-
async updateVector(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
metadata?: Record<string, any>;
|
|
247
|
-
},
|
|
248
|
-
namespace?: string,
|
|
249
|
-
): Promise<void> {
|
|
292
|
+
async updateVector(...args: ParamsToArgs<PineconeUpdateVectorParams> | PineconeUpdateVectorArgs): Promise<void> {
|
|
293
|
+
const params = this.normalizeArgs<PineconeUpdateVectorParams, PineconeUpdateVectorArgs>('updateVector', args, [
|
|
294
|
+
'namespace',
|
|
295
|
+
]);
|
|
296
|
+
const { indexName, id, update, namespace } = params;
|
|
250
297
|
try {
|
|
251
298
|
if (!update.vector && !update.metadata) {
|
|
252
299
|
throw new Error('No updates provided');
|
|
@@ -286,7 +333,7 @@ export class PineconeVector extends MastraVector {
|
|
|
286
333
|
Please use deleteVector() instead.
|
|
287
334
|
deleteIndexById() will be removed on May 20th, 2025.`,
|
|
288
335
|
);
|
|
289
|
-
await this.deleteVector(indexName, id, namespace);
|
|
336
|
+
await this.deleteVector({ indexName, id, namespace });
|
|
290
337
|
}
|
|
291
338
|
|
|
292
339
|
/**
|
|
@@ -297,7 +344,11 @@ export class PineconeVector extends MastraVector {
|
|
|
297
344
|
* @returns A promise that resolves when the deletion is complete.
|
|
298
345
|
* @throws Will throw an error if the deletion operation fails.
|
|
299
346
|
*/
|
|
300
|
-
async deleteVector(
|
|
347
|
+
async deleteVector(...args: ParamsToArgs<PineconeDeleteVectorParams> | PineconeDeleteVectorArgs): Promise<void> {
|
|
348
|
+
const params = this.normalizeArgs<PineconeDeleteVectorParams, PineconeDeleteVectorArgs>('deleteVector', args, [
|
|
349
|
+
'namespace',
|
|
350
|
+
]);
|
|
351
|
+
const { indexName, id, namespace } = params;
|
|
301
352
|
try {
|
|
302
353
|
const index = this.client.Index(indexName).namespace(namespace || '');
|
|
303
354
|
await index.deleteOne(id);
|