Class CorporaManager
- Namespace
- GenerativeAI.Clients
- Assembly
- GenerativeAI.dll
The CorpusManager class provides a client interface for managing corpora, documents, chunks, and permissions within a generative AI platform. It supports creating, retrieving, listing, querying, and deleting entities related to the corpus resources.
public class CorporaManager : BaseClient
- Inheritance
-
CorporaManager
- Inherited Members
- Extension Methods
Constructors
CorporaManager(IPlatformAdapter, HttpClient?, ILogger?)
Initializes a new instance of the CorporaManager class.
public CorporaManager(IPlatformAdapter platform, HttpClient? httpClient, ILogger? logger = null)
Parameters
platformIPlatformAdapterThe platform adapter for API communication.
httpClientHttpClientOptional HTTP client for API requests.
loggerILoggerOptional logger for diagnostic output.
Exceptions
- GenerativeAIException
Thrown when the platform authenticator is null.
Properties
ChunkClient
Gets the client for handling chunks.
public ChunkClient? ChunkClient { get; }
Property Value
CorporaClient
Gets the client for managing corpora.
public CorporaClient? CorporaClient { get; }
Property Value
CorpusPermissionClient
Gets the client for managing permissions on corpora.
public CorpusPermissionClient? CorpusPermissionClient { get; }
Property Value
DocumentsClient
Gets the client for performing operations on documents.
public DocumentsClient? DocumentsClient { get; }
Property Value
Methods
AddChunkAsync(string, Chunk, CancellationToken)
Adds a chunk to a document.
public Task<Chunk?> AddChunkAsync(string documentName, Chunk chunk, CancellationToken cancellationToken = default)
Parameters
documentNamestringThe name of the document to add the chunk to.
chunkChunkThe chunk to add.
cancellationTokenCancellationTokenThe cancellation token.
Returns
AddChunksAsync(string, List<Chunk>, CancellationToken)
Adds a chunk to a document.
public Task<List<Chunk>?> AddChunksAsync(string documentName, List<Chunk> chunks, CancellationToken cancellationToken = default)
Parameters
documentNamestringThe name of the document to add the chunk to.
chunksList<Chunk>The list of chunks to add.
cancellationTokenCancellationTokenThe cancellation token.
Returns
AddDocumentAsync(string, string, List<CustomMetadata>?, CancellationToken)
Adds a document to a corpus with the given display name and optional metadata.
public Task<Document?> AddDocumentAsync(string corpusName, string displayName, List<CustomMetadata>? metadata = null, CancellationToken cancellationToken = default)
Parameters
corpusNamestringThe name of the corpus to add the document to.
displayNamestringThe display name of the document.
metadataList<CustomMetadata>Optional metadata for the document.
cancellationTokenCancellationTokenThe cancellation token.
Returns
CreateCorpusAsync(string, CancellationToken)
Creates a new corpus with the given display name.
public Task<Corpus?> CreateCorpusAsync(string displayName, CancellationToken cancellationToken = default)
Parameters
displayNamestringThe display name of the corpus.
cancellationTokenCancellationTokenThe cancellation token.
Returns
CreateCorpusPermissionAsync(string, Permission, CancellationToken)
Creates a new permission for a corpus.
public Task<Permission?> CreateCorpusPermissionAsync(string corpusName, Permission permission, CancellationToken cancellationToken = default)
Parameters
corpusNamestringThe name of the corpus.
permissionPermissionThe permission to create.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<Permission>
The created permission.
DeleteChunkAsync(string, CancellationToken)
Deletes a chunk by its name.
public Task DeleteChunkAsync(string chunkName, CancellationToken cancellationToken = default)
Parameters
chunkNamestringThe name of the chunk.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the asynchronous operation.
DeleteCorpusAsync(string, bool, CancellationToken)
Deletes a corpus by its name.
public Task DeleteCorpusAsync(string corpusName, bool force = false, CancellationToken cancellationToken = default)
Parameters
corpusNamestringThe name of the corpus.
forceboolWhether to force delete the corpus.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the asynchronous operation.
DeleteDocumentAsync(string, bool, CancellationToken)
Deletes a document by its name.
public Task DeleteDocumentAsync(string documentName, bool force = false, CancellationToken cancellationToken = default)
Parameters
documentNamestringThe name of the document.
forceboolWhether to force delete the document.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the asynchronous operation.
DeletePermissionAsync(string, CancellationToken)
Deletes a permission by its name.
public Task DeletePermissionAsync(string permissionName, CancellationToken cancellationToken = default)
Parameters
permissionNamestringThe name of the permission.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the asynchronous operation.
GetChunkAsync(string, CancellationToken)
Gets a chunk by its name.
public Task<Chunk?> GetChunkAsync(string chunkName, CancellationToken cancellationToken = default)
Parameters
chunkNamestringThe name of the chunk.
cancellationTokenCancellationTokenThe cancellation token.
Returns
GetCorpusAsync(string, CancellationToken)
Gets a corpus by its name.
public Task<Corpus?> GetCorpusAsync(string corpusName, CancellationToken cancellationToken = default)
Parameters
corpusNamestringThe name of the corpus.
cancellationTokenCancellationTokenThe cancellation token.
Returns
GetDocumentAsync(string, CancellationToken)
Gets a document by its name.
public Task<Document?> GetDocumentAsync(string documentName, CancellationToken cancellationToken = default)
Parameters
documentNamestringThe name of the document.
cancellationTokenCancellationTokenThe cancellation token.
Returns
GetPermissionAsync(string, CancellationToken)
Gets a permission by its name.
public Task<Permission?> GetPermissionAsync(string permissionName, CancellationToken cancellationToken = default)
Parameters
permissionNamestringThe name of the permission.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<Permission>
The permission.
ListChunksAsync(string, CancellationToken)
Lists all chunks in a document.
public Task<List<Chunk>?> ListChunksAsync(string documentName, CancellationToken cancellationToken = default)
Parameters
documentNamestringThe name of the document.
cancellationTokenCancellationTokenThe cancellation token.
Returns
ListCorporaAsync(CancellationToken)
Lists all corpora.
public Task<List<Corpus>?> ListCorporaAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
ListCorpusPermissionsAsync(string, CancellationToken)
Lists all permissions for a corpus.
public Task<List<Permission>?> ListCorpusPermissionsAsync(string corpusName, CancellationToken cancellationToken = default)
Parameters
corpusNamestringThe name of the corpus.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<List<Permission>>
A list of all permissions for the corpus.
ListDocumentsAsync(string, CancellationToken)
Lists all documents in a corpus.
public Task<List<Document>?> ListDocumentsAsync(string corpusName, CancellationToken cancellationToken = default)
Parameters
corpusNamestringThe name of the corpus.
cancellationTokenCancellationTokenThe cancellation token.
Returns
QueryCorpusAsync(string, string, CancellationToken)
Performs a semantic search over a corpus.
public Task<QueryCorpusResponse?> QueryCorpusAsync(string corpusName, string query, CancellationToken cancellationToken = default)
Parameters
corpusNamestringThe name of the corpus to query.
querystringThe query string.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<QueryCorpusResponse>
The query response.
QueryDocumentAsync(string, string, CancellationToken)
Performs a semantic search over a document.
public Task<QueryDocumentResponse?> QueryDocumentAsync(string documentName, string query, CancellationToken cancellationToken = default)
Parameters
documentNamestringThe name of the document to query.
querystringThe query string.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<QueryDocumentResponse>
The query response.