Skip to content

Commit 8d49749

Browse files
authored
Migrated to latest rest api version (#11707)
1 parent 182f312 commit 8d49749

File tree

8 files changed

+100
-260
lines changed

8 files changed

+100
-260
lines changed

components/pinecone/actions/delete-vectors/delete-vectors.mjs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import utils from "../../common/utils.mjs";
44
export default {
55
key: "pinecone-delete-vectors",
66
name: "Delete Vectors",
7-
description: "Deletes one or more vectors by ID, from a single namespace. [See the docs](https://docs.pinecone.io/reference/delete_post).",
7+
description: "Deletes one or more vectors by ID, from a single namespace. [See the documentation](https://docs.pinecone.io/reference/api/data-plane/delete).",
88
type: "action",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
props: {
1111
app,
1212
indexName: {
@@ -15,10 +15,16 @@ export default {
1515
"indexName",
1616
],
1717
},
18-
projectId: {
18+
prefix: {
1919
propDefinition: [
2020
app,
21-
"projectId",
21+
"prefix",
22+
],
23+
},
24+
namespace: {
25+
propDefinition: [
26+
app,
27+
"namespace",
2228
],
2329
},
2430
ids: {
@@ -28,39 +34,27 @@ export default {
2834
propDefinition: [
2935
app,
3036
"vectorId",
31-
({
32-
indexName, projectId,
33-
}) => ({
34-
indexName,
35-
projectId,
36-
}),
37-
],
38-
},
39-
namespace: {
40-
propDefinition: [
41-
app,
42-
"namespace",
4337
],
4438
},
4539
},
4640
methods: {
4741
deleteVector(args = {}) {
48-
return this.app.create({
42+
return this.app.post({
4943
path: "/vectors/delete",
5044
...args,
5145
});
5246
},
5347
},
5448
async run({ $: step }) {
5549
const {
50+
deleteVector,
5651
indexName,
57-
projectId,
5852
ids,
5953
namespace,
6054
} = this;
6155

62-
await this.deleteVector({
63-
projectId,
56+
await deleteVector({
57+
step,
6458
indexName,
6559
data: {
6660
ids: utils.parseArray(ids),
@@ -69,5 +63,8 @@ export default {
6963
});
7064

7165
step.export("$summary", "Successfully deleted vectors");
66+
return {
67+
success: true,
68+
};
7269
},
7370
};

components/pinecone/actions/fetch-vectors/fetch-vectors.mjs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import app from "../../pinecone.app.mjs";
44
export default {
55
key: "pinecone-fetch-vectors",
66
name: "Fetch Vectors",
7-
description: "Looks up and returns vectors by ID, from a single namespace.. [See the docs](https://docs.pinecone.io/reference/fetch).",
7+
description: "Looks up and returns vectors by ID, from a single namespace.. [See the documentation](https://docs.pinecone.io/reference/api/data-plane/fetch).",
88
type: "action",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
props: {
1111
app,
1212
indexName: {
@@ -15,10 +15,10 @@ export default {
1515
"indexName",
1616
],
1717
},
18-
projectId: {
18+
namespace: {
1919
propDefinition: [
2020
app,
21-
"projectId",
21+
"namespace",
2222
],
2323
},
2424
ids: {
@@ -28,39 +28,35 @@ export default {
2828
propDefinition: [
2929
app,
3030
"vectorId",
31-
({
32-
indexName, projectId,
33-
}) => ({
34-
indexName,
35-
projectId,
36-
}),
3731
],
3832
},
39-
namespace: {
40-
propDefinition: [
41-
app,
42-
"namespace",
43-
],
33+
},
34+
methods: {
35+
fetchVectors(args = {}) {
36+
return this.app.makeRequest({
37+
path: "/vectors/fetch",
38+
...args,
39+
});
4440
},
4541
},
4642
async run({ $: step }) {
4743
const {
44+
fetchVectors,
4845
indexName,
49-
projectId,
5046
ids,
5147
namespace,
5248
} = this;
5349

54-
const response = await this.app.fetchVectors({
55-
projectId,
50+
const response = await fetchVectors({
51+
step,
5652
indexName,
5753
params: {
5854
ids: utils.parseArray(ids),
5955
namespace,
6056
},
6157
});
6258

63-
step.export("$summary", `Successfully fetched ${Object.keys(response?.vectors).length} vectors.`);
59+
step.export("$summary", `Successfully fetched \`${Object.keys(response.vectors).length}\` vector(s).`);
6460

6561
return response;
6662
},

components/pinecone/actions/query-ids/query-ids.mjs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import utils from "../../common/utils.mjs";
44
export default {
55
key: "pinecone-query-ids",
66
name: "Query IDs",
7-
description: "Searches a namespace, using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores. [See the docs](https://docs.pinecone.io/reference/query).",
7+
description: "Searches a namespace, using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores. [See the documentation](https://docs.pinecone.io/reference/api/data-plane/query).",
88
type: "action",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
props: {
1111
app,
1212
indexName: {
@@ -15,12 +15,6 @@ export default {
1515
"indexName",
1616
],
1717
},
18-
projectId: {
19-
propDefinition: [
20-
app,
21-
"projectId",
22-
],
23-
},
2418
topK: {
2519
type: "integer",
2620
label: "Top K",
@@ -32,7 +26,7 @@ export default {
3226
filter: {
3327
type: "object",
3428
label: "Filter",
35-
description: "The filter to apply. You can use vector metadata to limit your search. [See the docs](https://www.pinecone.io/docs/metadata-filtering/).",
29+
description: "The filter to apply. You can use vector metadata to limit your search. For guidance and examples, see [filtering-with-metadata](https://docs.pinecone.io/guides/data/filtering-with-metadata).",
3630
optional: true,
3731
},
3832
includeValues: {
@@ -59,27 +53,28 @@ export default {
5953
propDefinition: [
6054
app,
6155
"vectorId",
62-
({
63-
indexName, projectId,
64-
}) => ({
65-
indexName,
66-
projectId,
67-
}),
6856
],
6957
},
7058
vector: {
71-
optional: true,
7259
description: `${app.propDefinitions.vectorValues.description} Each request can contain only one of the parameters either **Vector Values** or **Vector ID**.`,
7360
propDefinition: [
7461
app,
7562
"vectorValues",
7663
],
7764
},
7865
},
66+
methods: {
67+
query(args = {}) {
68+
return this.app.post({
69+
path: "/query",
70+
...args,
71+
});
72+
},
73+
},
7974
async run({ $: step }) {
8075
const {
76+
query,
8177
indexName,
82-
projectId,
8378
id,
8479
vector,
8580
topK,
@@ -89,12 +84,16 @@ export default {
8984
namespace,
9085
} = this;
9186

92-
const response = await this.app.query({
93-
projectId,
87+
const vectorParsed = utils.parseArray(vector);
88+
89+
const response = await query({
90+
step,
9491
indexName,
9592
data: {
9693
id,
97-
vector: utils.parseArray(vector),
94+
...(vectorParsed.length && {
95+
vector: vectorParsed,
96+
}),
9897
topK,
9998
filter: utils.parse(filter),
10099
includeValues,

components/pinecone/actions/update-vector/update-vector.mjs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import app from "../../pinecone.app.mjs";
44
export default {
55
key: "pinecone-update-vector",
66
name: "Update Vector",
7-
description: "Updates vector in a namespace. If a value is included, it will overwrite the previous value. [See the docs](https://docs.pinecone.io/reference/update).",
7+
description: "Updates vector in a namespace. If a value is included, it will overwrite the previous value. [See the documentation](https://docs.pinecone.io/reference/api/data-plane/update).",
88
type: "action",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
props: {
1111
app,
1212
indexName: {
@@ -15,22 +15,10 @@ export default {
1515
"indexName",
1616
],
1717
},
18-
projectId: {
19-
propDefinition: [
20-
app,
21-
"projectId",
22-
],
23-
},
2418
id: {
2519
propDefinition: [
2620
app,
2721
"vectorId",
28-
({
29-
indexName, projectId,
30-
}) => ({
31-
indexName,
32-
projectId,
33-
}),
3422
],
3523
},
3624
values: {
@@ -54,33 +42,36 @@ export default {
5442
},
5543
methods: {
5644
updateVector(args = {}) {
57-
return this.app.create({
45+
return this.app.post({
5846
path: "/vectors/update",
5947
...args,
6048
});
6149
},
6250
},
6351
async run({ $: step }) {
6452
const {
53+
updateVector,
6554
indexName,
66-
projectId,
6755
id,
6856
values,
6957
metadata,
7058
namespace,
7159
} = this;
7260

73-
await this.updateVector({
74-
projectId,
61+
await updateVector({
62+
step,
7563
indexName,
7664
data: {
7765
id,
78-
values,
66+
values: utils.parseArray(values),
7967
setMetadata: utils.parse(metadata),
8068
namespace,
8169
},
8270
});
8371

8472
step.export("$summary", `Successfully updated vector with ID ${id}.`);
73+
return {
74+
success: true,
75+
};
8576
},
8677
};

0 commit comments

Comments
 (0)