@mastra/pinecone 0.2.13-alpha.1 → 0.2.13-alpha.3
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 +20 -0
- package/dist/_tsup-dts-rollup.d.cts +47 -0
- package/dist/_tsup-dts-rollup.d.ts +47 -0
- package/dist/index.cjs +79 -13
- package/dist/index.js +79 -13
- package/package.json +2 -2
- package/src/vector/index.test.ts +9 -9
- package/src/vector/index.ts +87 -15
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/pinecone@0.2.13-alpha.
|
|
2
|
+
> @mastra/pinecone@0.2.13-alpha.3 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 6083ms
|
|
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 9186ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m14.09 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 621ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m14.15 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 621ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/pinecone
|
|
2
2
|
|
|
3
|
+
## 0.2.13-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
8
|
+
- Updated dependencies [396be50]
|
|
9
|
+
- Updated dependencies [c3bd795]
|
|
10
|
+
- Updated dependencies [da082f8]
|
|
11
|
+
- Updated dependencies [a5810ce]
|
|
12
|
+
- @mastra/core@0.9.4-alpha.3
|
|
13
|
+
|
|
14
|
+
## 0.2.13-alpha.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [3171b5b]
|
|
19
|
+
- Updated dependencies [973e5ac]
|
|
20
|
+
- Updated dependencies [9e1eff5]
|
|
21
|
+
- @mastra/core@0.9.4-alpha.2
|
|
22
|
+
|
|
3
23
|
## 0.2.13-alpha.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -57,11 +57,58 @@ declare class PineconeVector extends MastraVector {
|
|
|
57
57
|
listIndexes(): Promise<string[]>;
|
|
58
58
|
describeIndex(indexName: string): Promise<PineconeIndexStats>;
|
|
59
59
|
deleteIndex(indexName: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
62
|
+
*
|
|
63
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
64
|
+
* @param indexName - The name of the index containing the vector.
|
|
65
|
+
* @param id - The ID of the vector to update.
|
|
66
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
67
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
68
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
69
|
+
* @param namespace - The namespace of the index (optional).
|
|
70
|
+
* @returns A promise that resolves when the update is complete.
|
|
71
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
72
|
+
*/
|
|
60
73
|
updateIndexById(indexName: string, id: string, update: {
|
|
61
74
|
vector?: number[];
|
|
62
75
|
metadata?: Record<string, any>;
|
|
63
76
|
}, namespace?: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
79
|
+
* @param indexName - The name of the index containing the vector.
|
|
80
|
+
* @param id - The ID of the vector to update.
|
|
81
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
82
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
83
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
84
|
+
* @param namespace - The namespace of the index (optional).
|
|
85
|
+
* @returns A promise that resolves when the update is complete.
|
|
86
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
87
|
+
*/
|
|
88
|
+
updateVector(indexName: string, id: string, update: {
|
|
89
|
+
vector?: number[];
|
|
90
|
+
metadata?: Record<string, any>;
|
|
91
|
+
}, namespace?: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
94
|
+
*
|
|
95
|
+
* Deletes a vector by its ID.
|
|
96
|
+
* @param indexName - The name of the index containing the vector.
|
|
97
|
+
* @param id - The ID of the vector to delete.
|
|
98
|
+
* @param namespace - The namespace of the index (optional).
|
|
99
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
100
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
101
|
+
*/
|
|
64
102
|
deleteIndexById(indexName: string, id: string, namespace?: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Deletes a vector by its ID.
|
|
105
|
+
* @param indexName - The name of the index containing the vector.
|
|
106
|
+
* @param id - The ID of the vector to delete.
|
|
107
|
+
* @param namespace - The namespace of the index (optional).
|
|
108
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
109
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
110
|
+
*/
|
|
111
|
+
deleteVector(indexName: string, id: string, namespace?: string): Promise<void>;
|
|
65
112
|
}
|
|
66
113
|
export { PineconeVector }
|
|
67
114
|
export { PineconeVector as PineconeVector_alias_1 }
|
|
@@ -57,11 +57,58 @@ declare class PineconeVector extends MastraVector {
|
|
|
57
57
|
listIndexes(): Promise<string[]>;
|
|
58
58
|
describeIndex(indexName: string): Promise<PineconeIndexStats>;
|
|
59
59
|
deleteIndex(indexName: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
62
|
+
*
|
|
63
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
64
|
+
* @param indexName - The name of the index containing the vector.
|
|
65
|
+
* @param id - The ID of the vector to update.
|
|
66
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
67
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
68
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
69
|
+
* @param namespace - The namespace of the index (optional).
|
|
70
|
+
* @returns A promise that resolves when the update is complete.
|
|
71
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
72
|
+
*/
|
|
60
73
|
updateIndexById(indexName: string, id: string, update: {
|
|
61
74
|
vector?: number[];
|
|
62
75
|
metadata?: Record<string, any>;
|
|
63
76
|
}, namespace?: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
79
|
+
* @param indexName - The name of the index containing the vector.
|
|
80
|
+
* @param id - The ID of the vector to update.
|
|
81
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
82
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
83
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
84
|
+
* @param namespace - The namespace of the index (optional).
|
|
85
|
+
* @returns A promise that resolves when the update is complete.
|
|
86
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
87
|
+
*/
|
|
88
|
+
updateVector(indexName: string, id: string, update: {
|
|
89
|
+
vector?: number[];
|
|
90
|
+
metadata?: Record<string, any>;
|
|
91
|
+
}, namespace?: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
94
|
+
*
|
|
95
|
+
* Deletes a vector by its ID.
|
|
96
|
+
* @param indexName - The name of the index containing the vector.
|
|
97
|
+
* @param id - The ID of the vector to delete.
|
|
98
|
+
* @param namespace - The namespace of the index (optional).
|
|
99
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
100
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
101
|
+
*/
|
|
64
102
|
deleteIndexById(indexName: string, id: string, namespace?: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Deletes a vector by its ID.
|
|
105
|
+
* @param indexName - The name of the index containing the vector.
|
|
106
|
+
* @param id - The ID of the vector to delete.
|
|
107
|
+
* @param namespace - The namespace of the index (optional).
|
|
108
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
109
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
110
|
+
*/
|
|
111
|
+
deleteVector(indexName: string, id: string, namespace?: string): Promise<void>;
|
|
65
112
|
}
|
|
66
113
|
export { PineconeVector }
|
|
67
114
|
export { PineconeVector as PineconeVector_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -206,23 +206,89 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
206
206
|
throw new Error(`Failed to delete Pinecone index: ${error.message}`);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
211
|
+
*
|
|
212
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
213
|
+
* @param indexName - The name of the index containing the vector.
|
|
214
|
+
* @param id - The ID of the vector to update.
|
|
215
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
216
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
217
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
218
|
+
* @param namespace - The namespace of the index (optional).
|
|
219
|
+
* @returns A promise that resolves when the update is complete.
|
|
220
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
221
|
+
*/
|
|
209
222
|
async updateIndexById(indexName, id, update, namespace) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
223
|
+
this.logger.warn(
|
|
224
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
225
|
+
Please use updateVector() instead.
|
|
226
|
+
updateIndexById() will be removed on May 20th, 2025.`
|
|
227
|
+
);
|
|
228
|
+
await this.updateVector(indexName, id, update, namespace);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
232
|
+
* @param indexName - The name of the index containing the vector.
|
|
233
|
+
* @param id - The ID of the vector to update.
|
|
234
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
235
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
236
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
237
|
+
* @param namespace - The namespace of the index (optional).
|
|
238
|
+
* @returns A promise that resolves when the update is complete.
|
|
239
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
240
|
+
*/
|
|
241
|
+
async updateVector(indexName, id, update, namespace) {
|
|
242
|
+
try {
|
|
243
|
+
if (!update.vector && !update.metadata) {
|
|
244
|
+
throw new Error("No updates provided");
|
|
245
|
+
}
|
|
246
|
+
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
247
|
+
const updateObj = { id };
|
|
248
|
+
if (update.vector) {
|
|
249
|
+
updateObj.values = update.vector;
|
|
250
|
+
}
|
|
251
|
+
if (update.metadata) {
|
|
252
|
+
updateObj.metadata = update.metadata;
|
|
253
|
+
}
|
|
254
|
+
await index.update(updateObj);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
220
257
|
}
|
|
221
|
-
await index.update(updateObj);
|
|
222
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
261
|
+
*
|
|
262
|
+
* Deletes a vector by its ID.
|
|
263
|
+
* @param indexName - The name of the index containing the vector.
|
|
264
|
+
* @param id - The ID of the vector to delete.
|
|
265
|
+
* @param namespace - The namespace of the index (optional).
|
|
266
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
267
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
268
|
+
*/
|
|
223
269
|
async deleteIndexById(indexName, id, namespace) {
|
|
224
|
-
|
|
225
|
-
|
|
270
|
+
this.logger.warn(
|
|
271
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
272
|
+
Please use deleteVector() instead.
|
|
273
|
+
deleteIndexById() will be removed on May 20th, 2025.`
|
|
274
|
+
);
|
|
275
|
+
await this.deleteVector(indexName, id, namespace);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Deletes a vector by its ID.
|
|
279
|
+
* @param indexName - The name of the index containing the vector.
|
|
280
|
+
* @param id - The ID of the vector to delete.
|
|
281
|
+
* @param namespace - The namespace of the index (optional).
|
|
282
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
283
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
284
|
+
*/
|
|
285
|
+
async deleteVector(indexName, id, namespace) {
|
|
286
|
+
try {
|
|
287
|
+
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
288
|
+
await index.deleteOne(id);
|
|
289
|
+
} catch (error) {
|
|
290
|
+
throw new Error(`Failed to delete vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
291
|
+
}
|
|
226
292
|
}
|
|
227
293
|
};
|
|
228
294
|
|
package/dist/index.js
CHANGED
|
@@ -204,23 +204,89 @@ var PineconeVector = class extends MastraVector {
|
|
|
204
204
|
throw new Error(`Failed to delete Pinecone index: ${error.message}`);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
209
|
+
*
|
|
210
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
211
|
+
* @param indexName - The name of the index containing the vector.
|
|
212
|
+
* @param id - The ID of the vector to update.
|
|
213
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
214
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
215
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
216
|
+
* @param namespace - The namespace of the index (optional).
|
|
217
|
+
* @returns A promise that resolves when the update is complete.
|
|
218
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
219
|
+
*/
|
|
207
220
|
async updateIndexById(indexName, id, update, namespace) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
this.logger.warn(
|
|
222
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
223
|
+
Please use updateVector() instead.
|
|
224
|
+
updateIndexById() will be removed on May 20th, 2025.`
|
|
225
|
+
);
|
|
226
|
+
await this.updateVector(indexName, id, update, namespace);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
230
|
+
* @param indexName - The name of the index containing the vector.
|
|
231
|
+
* @param id - The ID of the vector to update.
|
|
232
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
233
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
234
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
235
|
+
* @param namespace - The namespace of the index (optional).
|
|
236
|
+
* @returns A promise that resolves when the update is complete.
|
|
237
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
238
|
+
*/
|
|
239
|
+
async updateVector(indexName, id, update, namespace) {
|
|
240
|
+
try {
|
|
241
|
+
if (!update.vector && !update.metadata) {
|
|
242
|
+
throw new Error("No updates provided");
|
|
243
|
+
}
|
|
244
|
+
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
245
|
+
const updateObj = { id };
|
|
246
|
+
if (update.vector) {
|
|
247
|
+
updateObj.values = update.vector;
|
|
248
|
+
}
|
|
249
|
+
if (update.metadata) {
|
|
250
|
+
updateObj.metadata = update.metadata;
|
|
251
|
+
}
|
|
252
|
+
await index.update(updateObj);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
218
255
|
}
|
|
219
|
-
await index.update(updateObj);
|
|
220
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
259
|
+
*
|
|
260
|
+
* Deletes a vector by its ID.
|
|
261
|
+
* @param indexName - The name of the index containing the vector.
|
|
262
|
+
* @param id - The ID of the vector to delete.
|
|
263
|
+
* @param namespace - The namespace of the index (optional).
|
|
264
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
265
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
266
|
+
*/
|
|
221
267
|
async deleteIndexById(indexName, id, namespace) {
|
|
222
|
-
|
|
223
|
-
|
|
268
|
+
this.logger.warn(
|
|
269
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
270
|
+
Please use deleteVector() instead.
|
|
271
|
+
deleteIndexById() will be removed on May 20th, 2025.`
|
|
272
|
+
);
|
|
273
|
+
await this.deleteVector(indexName, id, namespace);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Deletes a vector by its ID.
|
|
277
|
+
* @param indexName - The name of the index containing the vector.
|
|
278
|
+
* @param id - The ID of the vector to delete.
|
|
279
|
+
* @param namespace - The namespace of the index (optional).
|
|
280
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
281
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
282
|
+
*/
|
|
283
|
+
async deleteVector(indexName, id, namespace) {
|
|
284
|
+
try {
|
|
285
|
+
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
286
|
+
await index.deleteOne(id);
|
|
287
|
+
} catch (error) {
|
|
288
|
+
throw new Error(`Failed to delete vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
289
|
+
}
|
|
224
290
|
}
|
|
225
291
|
};
|
|
226
292
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pinecone",
|
|
3
|
-
"version": "0.2.13-alpha.
|
|
3
|
+
"version": "0.2.13-alpha.3",
|
|
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.4-alpha.
|
|
24
|
+
"@mastra/core": "^0.9.4-alpha.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@microsoft/api-extractor": "^7.52.5",
|
package/src/vector/index.test.ts
CHANGED
|
@@ -282,7 +282,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
282
282
|
metadata: newMetaData,
|
|
283
283
|
};
|
|
284
284
|
|
|
285
|
-
await vectorDB.
|
|
285
|
+
await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
|
|
286
286
|
|
|
287
287
|
await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
|
|
288
288
|
|
|
@@ -311,7 +311,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
311
311
|
metadata: newMetaData,
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
-
await vectorDB.
|
|
314
|
+
await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
|
|
315
315
|
|
|
316
316
|
await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
|
|
317
317
|
|
|
@@ -338,7 +338,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
338
338
|
vector: newVector,
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
-
await vectorDB.
|
|
341
|
+
await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
|
|
342
342
|
|
|
343
343
|
await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
|
|
344
344
|
|
|
@@ -355,12 +355,12 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
355
355
|
}, 500000);
|
|
356
356
|
|
|
357
357
|
it('should throw exception when no updates are given', async () => {
|
|
358
|
-
await expect(vectorDB.
|
|
358
|
+
await expect(vectorDB.updateVector(indexNameUpdate, 'id', {})).rejects.toThrow('No updates provided');
|
|
359
359
|
});
|
|
360
360
|
|
|
361
361
|
it('should throw error for non-existent index', async () => {
|
|
362
362
|
const nonExistentIndex = 'non-existent-index';
|
|
363
|
-
await expect(vectorDB.
|
|
363
|
+
await expect(vectorDB.updateVector(nonExistentIndex, 'test-id', { vector: [1, 2, 3] })).rejects.toThrow();
|
|
364
364
|
});
|
|
365
365
|
|
|
366
366
|
it('should throw error for invalid vector dimension', async () => {
|
|
@@ -371,7 +371,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
371
371
|
});
|
|
372
372
|
|
|
373
373
|
await expect(
|
|
374
|
-
vectorDB.
|
|
374
|
+
vectorDB.updateVector(indexNameUpdate, id, { vector: [1, 2] }), // Wrong dimension
|
|
375
375
|
).rejects.toThrow();
|
|
376
376
|
}, 500000);
|
|
377
377
|
});
|
|
@@ -402,7 +402,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
402
402
|
expect(ids).toHaveLength(3);
|
|
403
403
|
const idToBeDeleted = ids[0];
|
|
404
404
|
|
|
405
|
-
await vectorDB.
|
|
405
|
+
await vectorDB.deleteVector(indexNameDelete, idToBeDeleted);
|
|
406
406
|
await waitUntilVectorsIndexed(vectorDB, indexNameDelete, 2, true);
|
|
407
407
|
|
|
408
408
|
// Query all vectors similar to the deleted one
|
|
@@ -490,7 +490,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
490
490
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
|
|
491
491
|
|
|
492
492
|
// Update in namespace1
|
|
493
|
-
await vectorDB.
|
|
493
|
+
await vectorDB.updateVector(indexNameNamespace, id, { metadata: { label: 'updated' } }, namespace1);
|
|
494
494
|
|
|
495
495
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
|
|
496
496
|
|
|
@@ -515,7 +515,7 @@ describe.skip('PineconeVector Integration Tests', () => {
|
|
|
515
515
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
|
|
516
516
|
|
|
517
517
|
// Delete from namespace1
|
|
518
|
-
await vectorDB.
|
|
518
|
+
await vectorDB.deleteVector(indexNameNamespace, id, namespace1);
|
|
519
519
|
|
|
520
520
|
await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 0, true);
|
|
521
521
|
|
package/src/vector/index.ts
CHANGED
|
@@ -200,8 +200,45 @@ export class PineconeVector extends MastraVector {
|
|
|
200
200
|
throw new Error(`Failed to delete Pinecone index: ${error.message}`);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
/**
|
|
204
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
205
|
+
*
|
|
206
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
207
|
+
* @param indexName - The name of the index containing the vector.
|
|
208
|
+
* @param id - The ID of the vector to update.
|
|
209
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
210
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
211
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
212
|
+
* @param namespace - The namespace of the index (optional).
|
|
213
|
+
* @returns A promise that resolves when the update is complete.
|
|
214
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
215
|
+
*/
|
|
204
216
|
async updateIndexById(
|
|
217
|
+
indexName: string,
|
|
218
|
+
id: string,
|
|
219
|
+
update: { vector?: number[]; metadata?: Record<string, any> },
|
|
220
|
+
namespace?: string,
|
|
221
|
+
): Promise<void> {
|
|
222
|
+
this.logger.warn(
|
|
223
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
224
|
+
Please use updateVector() instead.
|
|
225
|
+
updateIndexById() will be removed on May 20th, 2025.`,
|
|
226
|
+
);
|
|
227
|
+
await this.updateVector(indexName, id, update, namespace);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
232
|
+
* @param indexName - The name of the index containing the vector.
|
|
233
|
+
* @param id - The ID of the vector to update.
|
|
234
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
235
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
236
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
237
|
+
* @param namespace - The namespace of the index (optional).
|
|
238
|
+
* @returns A promise that resolves when the update is complete.
|
|
239
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
240
|
+
*/
|
|
241
|
+
async updateVector(
|
|
205
242
|
indexName: string,
|
|
206
243
|
id: string,
|
|
207
244
|
update: {
|
|
@@ -210,27 +247,62 @@ export class PineconeVector extends MastraVector {
|
|
|
210
247
|
},
|
|
211
248
|
namespace?: string,
|
|
212
249
|
): Promise<void> {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
250
|
+
try {
|
|
251
|
+
if (!update.vector && !update.metadata) {
|
|
252
|
+
throw new Error('No updates provided');
|
|
253
|
+
}
|
|
216
254
|
|
|
217
|
-
|
|
255
|
+
const index = this.client.Index(indexName).namespace(namespace || '');
|
|
218
256
|
|
|
219
|
-
|
|
257
|
+
const updateObj: UpdateOptions = { id };
|
|
220
258
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
259
|
+
if (update.vector) {
|
|
260
|
+
updateObj.values = update.vector;
|
|
261
|
+
}
|
|
224
262
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
263
|
+
if (update.metadata) {
|
|
264
|
+
updateObj.metadata = update.metadata;
|
|
265
|
+
}
|
|
228
266
|
|
|
229
|
-
|
|
267
|
+
await index.update(updateObj);
|
|
268
|
+
} catch (error: any) {
|
|
269
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
270
|
+
}
|
|
230
271
|
}
|
|
231
272
|
|
|
273
|
+
/**
|
|
274
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
275
|
+
*
|
|
276
|
+
* Deletes a vector by its ID.
|
|
277
|
+
* @param indexName - The name of the index containing the vector.
|
|
278
|
+
* @param id - The ID of the vector to delete.
|
|
279
|
+
* @param namespace - The namespace of the index (optional).
|
|
280
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
281
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
282
|
+
*/
|
|
232
283
|
async deleteIndexById(indexName: string, id: string, namespace?: string): Promise<void> {
|
|
233
|
-
|
|
234
|
-
|
|
284
|
+
this.logger.warn(
|
|
285
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
286
|
+
Please use deleteVector() instead.
|
|
287
|
+
deleteIndexById() will be removed on May 20th, 2025.`,
|
|
288
|
+
);
|
|
289
|
+
await this.deleteVector(indexName, id, namespace);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Deletes a vector by its ID.
|
|
294
|
+
* @param indexName - The name of the index containing the vector.
|
|
295
|
+
* @param id - The ID of the vector to delete.
|
|
296
|
+
* @param namespace - The namespace of the index (optional).
|
|
297
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
298
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
299
|
+
*/
|
|
300
|
+
async deleteVector(indexName: string, id: string, namespace?: string): Promise<void> {
|
|
301
|
+
try {
|
|
302
|
+
const index = this.client.Index(indexName).namespace(namespace || '');
|
|
303
|
+
await index.deleteOne(id);
|
|
304
|
+
} catch (error: any) {
|
|
305
|
+
throw new Error(`Failed to delete vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
306
|
+
}
|
|
235
307
|
}
|
|
236
308
|
}
|