From sgcWebSockets 2023.6.0 Pinecone API is supported.
Pinecone is a vector database that allows 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:
Find below an example of UPSERT a single vector with the Id = "id1".
procedure UpsertPinecone(const aIndexName, aProjectId: string; const aVector: Array of Double); var oPinecone: TsgcHTTP_API_Pinecone; oParams: TsgcHTTPPineconeVectorUpserts; oVectors: TsgcArrayOfVectorUpsert; begin oPinecone := TsgcHTTP_API_Pinecone.Create(nil); Try oPinecone.PineconeOptions.API := 'your-api-key'; oParams := TsgcHTTPPineconeVectorUpserts.Create; Try SetLength(oVectors, 1); oVectors[0] := TsgcHTTPPineconeVectorUpsert.Create; oVectors[0].Id := 'id1'; oVectors[0].Values := aVector; oParams.Vectors := oVectors; Pinecone.VectorsUpsert(aIndexName, aProjectId, oParams); Finally oParams.Free; End; Finally oPinecone.Free; End; end;
Find below an example of QUERY a single vector.
procedure QueryPinecone(const aIndexName, aProjectId: string; const aVector: Array of Double); var oParams: TsgcHTTPPineconeVectorQuery; begin oParams := TsgcHTTPPineconeVectorQuery.Create; Try oParams.Vector := aVector; Pinecone.VectorsQuery(aIndexName, aProjectId, oParams); Finally oParams.Free; End; end;
The following demo shows how the Pinecone API works, the demo is compiled for Windows and it's using the sgcWebSockets Pinecone API client.
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.