PineconeEmbeddingStorageService
Namespace: Wisej.AI.Services
Assembly: Wisej.AI
Represents a service for storing and retrieving embeddings using Pinecone.
- C#
- VB.NET
public class PineconeEmbeddingStorageService : IEmbeddingStorageService
Public Class PineconeEmbeddingStorageService
Inherits IEmbeddingStorageService
This class provides methods to store, retrieve, query, and remove embedded documents in a Pinecone vector database. It uses an HTTP client service to communicate with the Pinecone API.
Constructors
PineconeEmbeddingStorageService(url)
Initializes a new instance of the PineconeEmbeddingStorageService class.
| Name | Type | Description |
|---|---|---|
| url | String | The URL of the Pinecone service. Default is null. |
Properties
ApiKey
String: Gets or sets the API key for the Pinecone service. (Default: null)
MaxBatchSize
Int32: Gets or sets the maximum batch size used to store document vectors into the database. (Default: 100)
URL
String: Gets or sets the URL of the Pinecone service. (Default: null)
Methods
ExistsAsync(collectionName, documentName)
Checks if a document exists in the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
Returns: Task<Boolean>. A task that represents the asynchronous operation. The task result contains a boolean indicating whether the document exists.
GetApiKey()
Retrieves the API key for the Pinecone service.
Returns: String. The API key for the Pinecone service.
QueryAsync(collectionName, query, topN, minSimilarity, filter)
Queries the specified collection for documents similar to the given query vector.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| query | Single[] | The query vector. |
| topN | Int32 | The number of top similar documents to retrieve. |
| minSimilarity | Single | The minimum similarity threshold. |
| filter | Predicate<EmbeddedDocument> | An optional filter to apply to the documents. Default is null. |
Returns: Task<EmbeddedDocument[]>. A task that represents the asynchronous operation. The task result contains an array of EmbeddedDocument objects.
QueryAsync(collectionName, documentName, query, topN, minSimilarity)
Queries the specified collection for a document similar to the given query vector.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
| query | Single[] | The query vector. |
| topN | Int32 | The number of top similar documents to retrieve. |
| minSimilarity | Single | The minimum similarity threshold. |
Returns: Task<EmbeddedDocument>. A task that represents the asynchronous operation. The task result contains an EmbeddedDocument object.
Throws:
- ArgumentNullException Thrown when the document is null.
RemoveAsync(collectionName, filter)
Removes documents from the specified collection that match the given filter.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| filter | Predicate<EmbeddedDocument> | An optional filter to apply to the documents. Default is null. |
Returns: Task. A task that represents the asynchronous operation.
RemoveAsync(collectionName, documentName)
Removes a document from the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
Returns: Task. A task that represents the asynchronous operation.
RetrieveAsync(collectionName, documentName, includeEmbedding)
Retrieves a document from the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
| includeEmbedding | Boolean | A value indicating whether to include the embedding in the result. |
Returns: Task<EmbeddedDocument>. A task that represents the asynchronous operation. The task result contains an EmbeddedDocument object.
RetrieveAsync(collectionName, includeEmbedding, filter)
Retrieves documents from the specified collection that match the given filter.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| includeEmbedding | Boolean | A value indicating whether to include the embedding in the result. |
| filter | Predicate<EmbeddedDocument> | An optional filter to apply to the documents. Default is null. |
Returns: Task<EmbeddedDocument[]>. A task that represents the asynchronous operation. The task result contains an array of EmbeddedDocument objects.
StoreAsync(collectionName, document)
Stores a document in the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| document | EmbeddedDocument | The document to store. |
Returns: Task. A task that represents the asynchronous operation.
Throws:
- ArgumentNullException
Thrown when the document is
null.
Implements
| Name | Description |
|---|---|
| IEmbeddingStorageService | Represents a service for storing and querying embedded documents within specified collections. |