Class ChunkClient
- Namespace
- GenerativeAI.Clients
- Assembly
- GenerativeAI.dll
A client for interacting with the Chunks API.
public class ChunkClient : BaseClient
- Inheritance
-
ChunkClient
- Inherited Members
- Extension Methods
Constructors
ChunkClient(IPlatformAdapter, HttpClient?, ILogger?)
A client for managing and interacting with chunks in the Generative AI API.
public ChunkClient(IPlatformAdapter platform, HttpClient? httpClient = null, ILogger? logger = null)
Parameters
platformIPlatformAdapterThe platform adapter for handling platform-specific operations.
httpClientHttpClientOptional HTTP client for sending requests. Defaults to null.
loggerILoggerOptional logger for logging purposes. Defaults to null.
- See Also
Methods
AddAuthorizationHeader(HttpRequestMessage, bool, CancellationToken)
Adds the authorization header to the HTTP request.
protected override Task AddAuthorizationHeader(HttpRequestMessage request, bool requireAccessToken = false, CancellationToken cancellationToken = default)
Parameters
requestHttpRequestMessageThe HTTP request message.
requireAccessTokenboolWhether an access token is required.
cancellationTokenCancellationTokenA cancellation token to cancel the operation.
Returns
- Task
A task representing the asynchronous operation.
BatchCreateChunksAsync(string, List<CreateChunkRequest>, CancellationToken)
Batches create Chunk resources.
public Task<BatchCreateChunksResponse?> BatchCreateChunksAsync(string parent, List<CreateChunkRequest> requests, CancellationToken cancellationToken = default)
Parameters
parentstringThe name of the Document where this batch of Chunks will be created. Example:
corpora/my-corpus-123/documents/the-doc-abcrequestsList<CreateChunkRequest>The request messages specifying the Chunks to create. A maximum of 100 Chunks can be created in a batch.
cancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- Task<BatchCreateChunksResponse>
A list of created Chunks.
- See Also
BatchDeleteChunksAsync(string, List<DeleteChunkRequest>, CancellationToken)
Batches delete Chunk resources.
public Task BatchDeleteChunksAsync(string parent, List<DeleteChunkRequest> requests, CancellationToken cancellationToken = default)
Parameters
parentstringThe name of the Document containing the Chunks to delete. Example:
corpora/my-corpus-123/documents/the-doc-abcrequestsList<DeleteChunkRequest>The request messages specifying the Chunks to delete.
cancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- Task
A task representing the asynchronous operation.
- See Also
BatchUpdateChunksAsync(string, List<UpdateChunkRequest>, CancellationToken)
Batches update Chunk resources.
public Task<BatchUpdateChunksResponse?> BatchUpdateChunksAsync(string parent, List<UpdateChunkRequest> requests, CancellationToken cancellationToken = default)
Parameters
parentstringThe name of the Document containing the Chunks to update. Example:
corpora/my-corpus-123/documents/the-doc-abcrequestsList<UpdateChunkRequest>The request messages specifying the Chunks to update. A maximum of 100 Chunks can be updated in a batch.
cancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- Task<BatchUpdateChunksResponse>
A list of updated Chunks.
- See Also
CreateChunkAsync(string, Chunk, CancellationToken)
Creates a new Chunk resource.
public Task<Chunk?> CreateChunkAsync(string parent, Chunk chunk, CancellationToken cancellationToken = default)
Parameters
parentstringThe name of the Document where this Chunk will be created. Example:
corpora/my-corpus-123/documents/the-doc-abcchunkChunkThe Chunk to create.
cancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- See Also
DeleteChunkAsync(string, CancellationToken)
Deletes a Chunk resource.
public Task DeleteChunkAsync(string name, CancellationToken cancellationToken = default)
Parameters
namestringThe resource name of the Chunk to delete. Example:
corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunkcancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- Task
A task representing the asynchronous operation.
- See Also
GetChunkAsync(string, CancellationToken)
Gets a specific Chunk resource.
public Task<Chunk?> GetChunkAsync(string name, CancellationToken cancellationToken = default)
Parameters
namestringThe resource name of the Chunk to retrieve. Example:
corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunkcancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- See Also
ListChunksAsync(string, int?, string?, CancellationToken)
Lists available Chunk resources.
public Task<ListChunksResponse?> ListChunksAsync(string parent, int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)
Parameters
parentstringThe name of the Document containing Chunks. Example:
corpora/my-corpus-123/documents/the-doc-abcpageSizeint?The maximum number of Chunk resources to return.
pageTokenstringA page token, received from a previous ListChunksAsync(string, int?, string?, CancellationToken) call.
cancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- Task<ListChunksResponse>
A list of Chunk resources.
- See Also
UpdateChunkAsync(Chunk, string, CancellationToken)
Updates a Chunk resource.
public Task<Chunk?> UpdateChunkAsync(Chunk chunk, string updateMask, CancellationToken cancellationToken = default)
Parameters
chunkChunkThe Chunk resource to update.
updateMaskstringThe list of fields to update. Currently, this only supports updating
customMetadataanddata.cancellationTokenCancellationTokenA cancellation token to cancel the request.
Returns
- See Also