Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Update Pinecone integration to latest version of API #11707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 17 additions & 20 deletions components/pinecone/actions/delete-vectors/delete-vectors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import utils from "../../common/utils.mjs";
export default {
key: "pinecone-delete-vectors",
name: "Delete Vectors",
description: "Deletes one or more vectors by ID, from a single namespace. [See the docs](https://docs.pinecone.io/reference/delete_post).",
description: "Deletes one or more vectors by ID, from a single namespace. [See the documentation](https://docs.pinecone.io/reference/api/data-plane/delete).",
type: "action",
version: "0.0.1",
version: "0.0.2",
props: {
app,
indexName: {
Expand All @@ -15,10 +15,16 @@ export default {
"indexName",
],
},
projectId: {
prefix: {
propDefinition: [
app,
"projectId",
"prefix",
],
},
namespace: {
propDefinition: [
app,
"namespace",
],
},
ids: {
Expand All @@ -28,39 +34,27 @@ export default {
propDefinition: [
app,
"vectorId",
({
indexName, projectId,
}) => ({
indexName,
projectId,
}),
],
},
namespace: {
propDefinition: [
app,
"namespace",
],
},
},
methods: {
deleteVector(args = {}) {
return this.app.create({
return this.app.post({
path: "/vectors/delete",
...args,
});
},
},
async run({ $: step }) {
const {
deleteVector,
indexName,
projectId,
ids,
namespace,
} = this;

await this.deleteVector({
projectId,
await deleteVector({
step,
indexName,
data: {
ids: utils.parseArray(ids),
Expand All @@ -69,5 +63,8 @@ export default {
});

step.export("$summary", "Successfully deleted vectors");
return {
success: true,
};
},
};
34 changes: 15 additions & 19 deletions components/pinecone/actions/fetch-vectors/fetch-vectors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import app from "../../pinecone.app.mjs";
export default {
key: "pinecone-fetch-vectors",
name: "Fetch Vectors",
description: "Looks up and returns vectors by ID, from a single namespace.. [See the docs](https://docs.pinecone.io/reference/fetch).",
description: "Looks up and returns vectors by ID, from a single namespace.. [See the documentation](https://docs.pinecone.io/reference/api/data-plane/fetch).",
type: "action",
version: "0.0.1",
version: "0.0.2",
props: {
app,
indexName: {
Expand All @@ -15,10 +15,10 @@ export default {
"indexName",
],
},
projectId: {
namespace: {
propDefinition: [
app,
"projectId",
"namespace",
],
},
ids: {
Expand All @@ -28,39 +28,35 @@ export default {
propDefinition: [
app,
"vectorId",
({
indexName, projectId,
}) => ({
indexName,
projectId,
}),
],
},
namespace: {
propDefinition: [
app,
"namespace",
],
},
methods: {
fetchVectors(args = {}) {
return this.app.makeRequest({
path: "/vectors/fetch",
...args,
});
},
},
async run({ $: step }) {
const {
fetchVectors,
indexName,
projectId,
ids,
namespace,
} = this;

const response = await this.app.fetchVectors({
projectId,
const response = await fetchVectors({
step,
indexName,
params: {
ids: utils.parseArray(ids),
namespace,
},
});

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

return response;
},
Expand Down
39 changes: 19 additions & 20 deletions components/pinecone/actions/query-ids/query-ids.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import utils from "../../common/utils.mjs";
export default {
key: "pinecone-query-ids",
name: "Query IDs",
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).",
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).",
type: "action",
version: "0.0.1",
version: "0.0.2",
props: {
app,
indexName: {
Expand All @@ -15,12 +15,6 @@ export default {
"indexName",
],
},
projectId: {
propDefinition: [
app,
"projectId",
],
},
topK: {
type: "integer",
label: "Top K",
Expand All @@ -32,7 +26,7 @@ export default {
filter: {
type: "object",
label: "Filter",
description: "The filter to apply. You can use vector metadata to limit your search. [See the docs](https://www.pinecone.io/docs/metadata-filtering/).",
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).",
optional: true,
},
includeValues: {
Expand All @@ -59,27 +53,28 @@ export default {
propDefinition: [
app,
"vectorId",
({
indexName, projectId,
}) => ({
indexName,
projectId,
}),
],
},
vector: {
optional: true,
description: `${app.propDefinitions.vectorValues.description} Each request can contain only one of the parameters either **Vector Values** or **Vector ID**.`,
propDefinition: [
app,
"vectorValues",
],
},
},
methods: {
query(args = {}) {
return this.app.post({
path: "/query",
...args,
});
},
},
async run({ $: step }) {
const {
query,
indexName,
projectId,
id,
vector,
topK,
Expand All @@ -89,12 +84,16 @@ export default {
namespace,
} = this;

const response = await this.app.query({
projectId,
const vectorParsed = utils.parseArray(vector);

const response = await query({
step,
indexName,
data: {
id,
vector: utils.parseArray(vector),
...(vectorParsed.length && {
vector: vectorParsed,
}),
topK,
filter: utils.parse(filter),
includeValues,
Expand Down
29 changes: 10 additions & 19 deletions components/pinecone/actions/update-vector/update-vector.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import app from "../../pinecone.app.mjs";
export default {
key: "pinecone-update-vector",
name: "Update Vector",
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).",
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).",
type: "action",
version: "0.0.1",
version: "0.0.2",
props: {
app,
indexName: {
Expand All @@ -15,22 +15,10 @@ export default {
"indexName",
],
},
projectId: {
propDefinition: [
app,
"projectId",
],
},
id: {
propDefinition: [
app,
"vectorId",
({
indexName, projectId,
}) => ({
indexName,
projectId,
}),
],
},
values: {
Expand All @@ -54,33 +42,36 @@ export default {
},
methods: {
updateVector(args = {}) {
return this.app.create({
return this.app.post({
path: "/vectors/update",
...args,
});
},
},
async run({ $: step }) {
const {
updateVector,
indexName,
projectId,
id,
values,
metadata,
namespace,
} = this;

await this.updateVector({
projectId,
await updateVector({
step,
indexName,
data: {
id,
values,
values: utils.parseArray(values),
setMetadata: utils.parse(metadata),
namespace,
},
});

step.export("$summary", `Successfully updated vector with ID ${id}.`);
return {
success: true,
};
},
};