Skip to main content

snippets_js

Integration

New integration from credential
const pineconeClient = yepcode.integration.pinecone('credential-slug')
New integration from plain authentication data
const { Pinecone } = require('@pinecone-database/pinecone');

const pineconeClient = new Pinecone({
apiKey: 'YOUR_API_KEY',
});

Create Index

Creates an index
await pineconeClient.createIndex({
name: "example-index",
dimension: 1024,
});

List Indexes

Lists all indexes in your project
const indexesList = await pineconeClient.listIndexes();

Construct an index Object

Construct an index objet with an existing index name
const index = pineconeClient.index('example-index');
// Now perform index operations
await index.fetch(['1']);

Describe Index

Logs information about an index in your project
const indexDescription = await pineconeClient.describeIndex({
indexName: "example-index",
});

Delete Index

Deletes an index
await pineconeClient.deleteIndex({
indexName: "example-index",
});

Upsert Vectors

Upserts vector to an index
const index = pineconeClient.index("example-index");
await index.upsert([
{
id: "vec1",
values: [0.1, 0.2, 0.3, 0.4],
metadata: {
genre: "drama",
},
},
{
id: "vec2",
values: [0.2, 0.3, 0.4, 0.5],
metadata: {
genre: "action",
},
},
]);

Query and Index

Queries an index filtering
await pineconeClient.configureIndex({
indexName: "example-index",
patchRequest: {
replicas: 2,
podType: "p2",
},
});

Update Vectors

Updates a vector
const index = pineconeClient.index("example-index");
const updateResponse = await index.update({
id: "vec1",
values: [0.1, 0.2, 0.3, 0.4],
setMetadata: { genre: "drama" },
namespace: "example-namespace",
});

Delete Vectors

Deletes a vector
const index = pineconeClient.index("example-index");
await index.deleteOne("vec1")
await index.deleteMany(["vec1", "vec2"]);
await index.deleteAll()

Create Collection

Creates a collection from an index
const createCollectionRequest = {
name: "example-collection",
source: "example-index",
};

await pineconeClient.createCollection({
createCollectionRequest,
});

List Collections

List the collections in your current project
const collectionsList = await pineconeClient.listCollections();

Describe Collection

Returns a description of one collection
const collectionDescription = await pineconeClient.describeCollection("example-collection");

Delete Collection

Deletes a collection
await pineconeClient.deleteCollection("example-collection");