Pinecone is a vector database that allows you to upload / query / delete vector data in an easy and powerful way.
Pinecone has a public API that allows third-parties to integrate pinecone into it's own applications. The component TsgcHTTP_API_Pinecone is a wrapper over the Pinecone API.
Before start, you must register in Pinecone website and request an API. This API key is used to send the API requests and must be set in the property PineconeOptions.ApiKey of the TsgcHTTP_API_Pinecone component.
The following methods are supported:
| Method | Parameters | Description |
| IndexesList | This operation returns a list of your Pinecone indexes. | |
| IndexCreate | TsgcHTTPPineconeIndexCreate | This operation creates a Pinecone index. You can use it to specify the measure of similarity, the dimension of vectors to be stored in the index, the numbers of replicas to use, and more. |
| IndexDescribe | Index Name | Get a description of an index. |
| IndexDelete | Index Name | This operation deletes an existing index. |
| IndexConfigure | Index Name, Replicas, PodType | This operation specifies the pod type and number of replicas for an index. |
The following methods are supported:
| Method | Parameters | Description |
| CollectionsList | This operation returns a list of your Pinecone collections. | |
| CollectionCreate | Collection Name, Source | This operation creates a Pinecone collection. |
| CollectionDescribe | Collection Name | Get a description of a collection. |
| CollectionDelete | Collection Name | This operation deletes an existing collection. |
The following methods are supported:
| Method | Parameters | Description |
| VectorsDescribeIndexStats | Index Name, Project Id, Filter | The DescribeIndexStats operation returns statistics about the index's contents, including the vector count per namespace and the number of dimensions. |
| VectorsQuery | Index Name, Project Id, Params | The Query operation searches a namespace, using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores. |
| VectorsDelete | Index Name, Project Id, Params | The Delete operation deletes vectors, by id, from a single namespace. You can delete items by their id, from a single namespace. |
| VectorsFetch |
Index Name, Project Id, Ids |
The Fetch operation looks up and returns vectors, by ID, from a single namespace. The returned vectors include the vector data and/or metadata. |
| VectorsUpdate | Index Name, Project Id, Params | The Update operation updates vector in a namespace. If a value is included, it will overwrite the previous value. If a set_metadata is included, the values of the fields specified in it will be added or overwrite the previous value. |
| VectorsUpsert | Index Name, Project Id, Params | The Upsert operation writes vectors into a namespace. If a new value is upserted for an existing vector id, it will overwrite the previous value. |
Find below an example of UPSERT a single vector with the Id = "id1".
void UpsertPinecone(const String aIndexName, const String aProjectId, const std::vector<double> aVector)
{
TsgcHTTP_API_Pinecone* oPinecone = new TsgcHTTP_API_Pinecone(NULL);
try
{
oPinecone->PineconeOptions.API = "your-api-key";
TsgcHTTPPineconeVectorUpserts* oParams = new TsgcHTTPPineconeVectorUpserts();
try
{
TsgcArrayOfVectorUpsert oVectors;
oVectors.push_back(new TsgcHTTPPineconeVectorUpsert());
oVectors[0]->Id = "id1";
oVectors[0]->Values = aVector;
oParams->Vectors = oVectors;
oPinecone->VectorsUpsert(aIndexName, aProjectId, oParams);
}
__finally
{
oParams->Free();
}
}
__finally
{
oPinecone->Free();
}
}
Find below an example of QUERY a single vector.
void QueryPinecone(const string aIndexName, const string aProjectId, const std::vector<double>& aVector)
{
TsgcHTTPPineconeVectorQuery* oParams = new TsgcHTTPPineconeVectorQuery();
try
{
oParams->Vector = aVector;
Pinecone.VectorsQuery(aIndexName, aProjectId, oParams);
}
__finally
{
oParams->Free();
}
}