Table of Contents

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

platform IPlatformAdapter

The platform adapter for API communication.

httpClient HttpClient

Optional HTTP client for API requests.

logger ILogger

Optional 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

ChunkClient

CorporaClient

Gets the client for managing corpora.

public CorporaClient? CorporaClient { get; }

Property Value

CorporaClient

CorpusPermissionClient

Gets the client for managing permissions on corpora.

public CorpusPermissionClient? CorpusPermissionClient { get; }

Property Value

CorpusPermissionClient

DocumentsClient

Gets the client for performing operations on documents.

public DocumentsClient? DocumentsClient { get; }

Property Value

DocumentsClient

Methods

AddChunkAsync(string, Chunk, CancellationToken)

Adds a chunk to a document.

public Task<Chunk?> AddChunkAsync(string documentName, Chunk chunk, CancellationToken cancellationToken = default)

Parameters

documentName string

The name of the document to add the chunk to.

chunk Chunk

The chunk to add.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Chunk>

The created chunk.

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

documentName string

The name of the document to add the chunk to.

chunks List<Chunk>

The list of chunks to add.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<List<Chunk>>

The created chunk.

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

corpusName string

The name of the corpus to add the document to.

displayName string

The display name of the document.

metadata List<CustomMetadata>

Optional metadata for the document.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Document>

The created document.

CreateCorpusAsync(string, CancellationToken)

Creates a new corpus with the given display name.

public Task<Corpus?> CreateCorpusAsync(string displayName, CancellationToken cancellationToken = default)

Parameters

displayName string

The display name of the corpus.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Corpus>

The created corpus.

CreateCorpusPermissionAsync(string, Permission, CancellationToken)

Creates a new permission for a corpus.

public Task<Permission?> CreateCorpusPermissionAsync(string corpusName, Permission permission, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the corpus.

permission Permission

The permission to create.

cancellationToken CancellationToken

The 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

chunkName string

The name of the chunk.

cancellationToken CancellationToken

The 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

corpusName string

The name of the corpus.

force bool

Whether to force delete the corpus.

cancellationToken CancellationToken

The 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

documentName string

The name of the document.

force bool

Whether to force delete the document.

cancellationToken CancellationToken

The 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

permissionName string

The name of the permission.

cancellationToken CancellationToken

The 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

chunkName string

The name of the chunk.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Chunk>

The chunk.

GetCorpusAsync(string, CancellationToken)

Gets a corpus by its name.

public Task<Corpus?> GetCorpusAsync(string corpusName, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the corpus.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Corpus>

The corpus.

GetDocumentAsync(string, CancellationToken)

Gets a document by its name.

public Task<Document?> GetDocumentAsync(string documentName, CancellationToken cancellationToken = default)

Parameters

documentName string

The name of the document.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Document>

The document.

GetPermissionAsync(string, CancellationToken)

Gets a permission by its name.

public Task<Permission?> GetPermissionAsync(string permissionName, CancellationToken cancellationToken = default)

Parameters

permissionName string

The name of the permission.

cancellationToken CancellationToken

The 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

documentName string

The name of the document.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<List<Chunk>>

A list of all chunks in the document.

ListCorporaAsync(CancellationToken)

Lists all corpora.

public Task<List<Corpus>?> ListCorporaAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<List<Corpus>>

A list of all corpora.

ListCorpusPermissionsAsync(string, CancellationToken)

Lists all permissions for a corpus.

public Task<List<Permission>?> ListCorpusPermissionsAsync(string corpusName, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the corpus.

cancellationToken CancellationToken

The 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

corpusName string

The name of the corpus.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<List<Document>>

A list of all documents in the corpus.

QueryCorpusAsync(string, string, CancellationToken)

Performs a semantic search over a corpus.

public Task<QueryCorpusResponse?> QueryCorpusAsync(string corpusName, string query, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the corpus to query.

query string

The query string.

cancellationToken CancellationToken

The 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

documentName string

The name of the document to query.

query string

The query string.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<QueryDocumentResponse>

The query response.