Releases: pinecone-io/pinecone-dotnet-client
v2.1.0 Release
This version of the Pinecone .NET Client introduces the ClientOptions.IsTlsEnabled
property which you are required to set to false
if you want to test the Client against an HTTP endpoint.
Features
IsTlsEnabled
Parts of the Client dynamically retrieve API hostnames to interact with which default to using HTTPS. To have the Client default to using HTTP instead, you can set the ClientOptions.IsTlsEnabled
to false
.
Now you can use the Pinecone Client against a local HTTP URL:
using Pinecone;
var pinecone = new PineconeClient("PINECONE_API_KEY",
new ClientOptions
{
BaseUrl = "http://localhost:5080",
IsTlsEnabled = false
}
);
// Create serverless index
await pinecone.CreateIndexAsync(new CreateIndexRequest
{
Name = "serverless-index",
Dimension = 3,
Metric = CreateIndexRequestMetric.Cosine,
Spec = new ServerlessIndexSpec
{
Serverless = new ServerlessSpec
{
Cloud = ServerlessSpecCloud.Aws,
Region = "us-east-1",
}
},
DeletionProtection = DeletionProtection.Disabled
});
// Create pod index
await pinecone.CreateIndexAsync(new CreateIndexRequest
{
Name = "pod-index",
Dimension = 3,
Metric = CreateIndexRequestMetric.Cosine,
Spec = new PodIndexSpec
{
Pod = new PodSpec
{
Environment = "us-east-1-aws",
PodType = "p1.x1",
Pods = 1,
Replicas = 1,
Shards = 1,
}
},
DeletionProtection = DeletionProtection.Disabled
});
// Describe serverless index
await pinecone.DescribeIndexAsync("serverless-index");
// Describe pod index
await pinecone.DescribeIndexAsync("pod-index");
// Get index connection object for serverless-index
var serverlessIndexConnection = pinecone.Index("serverless-index");
// Get index connection object for pod-index
var podIndexConnection = pinecone.Index("pod-index");
// Upsert records into serverless index
await serverlessIndexConnection.UpsertAsync(new UpsertRequest()
{
Namespace = "v1",
Vectors = new List<Vector>
{
new Vector { Id = "1", Values = new ReadOnlyMemory<float>([1f, 2f, 3f]) }
}
});
// Upsert records into pod index
await podIndexConnection.UpsertAsync(new UpsertRequest()
{
Namespace = "v1",
Vectors = new List<Vector>
{
new Vector { Id = "1", Values = new ReadOnlyMemory<float>([1f, 2f, 3f]) }
}
});
// Query by vectorId from serverless index
await serverlessIndexConnection.QueryAsync(new QueryRequest
{
TopK = 10,
Id = "3",
Namespace = "v1",
});
// Query by vectorId from pod index
await podIndexConnection.QueryAsync(new QueryRequest
{
TopK = 10,
Id = "3",
Namespace = "v1",
});
// Delete serverless index
await pinecone.DeleteIndexAsync("serverless-index");
// Delete pod index
await pinecone.DeleteIndexAsync("pod-index");
What's Changed
- feat: Add
IsTlsEnabled
client option by @fern-support in #35 - 🌿 Fern Regeneration -- December 4, 2024 by @fern-api in #36
Full Changelog: 2.0.0...2.1.0
v2.0.0 Release
This version of the Pinecone .NET SDK introduces inference
and imports
. It also supports version 2024-10
of the Pinecone API. You can read more about versioning here.
Features
Embed
The Inference
has an operation called Embed
which allows users to generate embeddings for input data.
using Pinecone;
var pinecone = new PineconeClient("PINECONE_API_KEY");
// Prepare input sentences to be embedded
List<EmbedRequestInputsItem> inputs =
[
new()
{
Text = "The quick brown fox jumps over the lazy dog."
},
new()
{
Text = "Lorem ipsum"
}
];
// Specify the embedding model and parameters
var embeddingModel = "multilingual-e5-large";
// Generate embeddings for the input data
var embeddings = await pinecone.Inference.EmbedAsync(new EmbedRequest()
{
Model = embeddingModel,
Inputs = inputs,
Parameters = new EmbedRequestParameters()
{
InputType = "query",
Truncate = "END"
}
});
// Get embedded data
var embeddedData = embeddings.Data;
Rerank
The Inference
has another operation called Rerank
which provides users the ability to rerank documents in descending relevance-order against a given query. Reranking documents is a common "second-pass" ranking strategy broadly used in retrieval applications.
using Pinecone;
var pinecone = new PineconeClient("PINECONE_API_KEY");
// The model to use for reranking
var model = "bge-reranker-v2-m3";
// The query to rerank documents against
var query = "The tech company Apple is known for its innovative products like the iPhone.";
// Add the documents to rerank
var documents = new List<Dictionary<string, string>>
{
new()
{
["id"] = "vec1",
["my_field"] = "Apple is a popular fruit known for its sweetness and crisp texture."
},
new()
{
["id"] = "vec2",
["my_field"] = "Many people enjoy eating apples as a healthy snack."
},
new()
{
["id"] = "vec3",
["my_field"] =
"Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."
},
new()
{
["id"] = "vec4",
["my_field"] = "An apple a day keeps the doctor away, as the saying goes."
}
};
// The fields to rank the documents by. If not provided, the default is "text"
var rankFields = new List<string> { "my_field" };
// The number of results to return sorted by relevance. Defaults to the number of inputs
int topN = 2;
// Whether to return the documents in the response
bool returnDocuments = true;
// Additional model-specific parameters for the reranker
var parameters = new Dictionary<string, string>
{
["truncate"] = "END"
};
// Send ranking request
var result = await pinecone.Inference.RerankAsync(
new RerankRequest
{
Model = model,
Query = query,
Documents = documents,
RankFields = rankFields,
TopN = topN,
Parameters = parameters
});
// Get ranked data
var data = result.Data;
Import
Index
now exposes additional methods for working with import
operations. An import
is a long-running, asynchronous operation that gives users the ability to import vectors directly from object storage (e.g. S3) into a Pinecone index. It is intended to be used with large-scale jobs. For small-scale jobs (e.g. <1000 vectors), we recommend continuing to use upsert.
using Pinecone;
...
// Initialize pinecone object
var pinecone = new PineconeClient("PINECONE_API_KEY");
// Get async imports connection object
var index = pinecone.Index("PINECONE_INDEX_NAME");
// s3 uri
var uri = "s3://path/to/file.parquet";
// Start an import
var startImportResponse = await index.StartBulkImportAsync(new StartImportRequest
{
Uri = uri,
IntegrationId = "123-456-789",
ErrorMode = new ImportErrorMode { OnError = ImportErrorModeOnError.Continue }
});
// List imports
var listimportResponse = await index.ListBulkImportsAsync(new ListBulkImportsRequest
{
Limit = 100,
PaginationToken = "some-pagination-token"
});
// Describe import
var importDetails = await index.DescribeBulkImportAsync("1");
// Cancel import
var cancelResponse = await index.CancelBulkImportAsync("2");
v1.0.0 Release
This is the first public release of the Pinecone .NET client. The client supports both control and data plane operations for pods
, serverless
, and free-tier
indexes. Below are the supported operations:
Control Plane Operations:
- Index Operations:
- Create Index
- List Index
- Describe Index
- Delete Index
- Configure Index
- Collection Operations:
- Create Collection
- List Collection
- Describe Collection
- Delete Collection
Data Plane Operations:
- Upsert Vectors
- Query Vectors
- Fetch Vectors
- Update Vectors
- Delete Vectors
- List Vectors
- Get Index Stats
Please note that all data plane operations use gRPC, while control plane operations use REST. Users also have the ability to configure retries, timeouts, and the HTTP proxy. For detailed information on how to use the client, please refer to the README.
1.0.0-rc.1
Initial release.