Table of Contents

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

platform IPlatformAdapter

The platform adapter for handling platform-specific operations.

httpClient HttpClient

Optional HTTP client for sending requests. Defaults to null.

logger ILogger

Optional 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

request HttpRequestMessage

The HTTP request message.

requireAccessToken bool

Whether an access token is required.

cancellationToken CancellationToken

A 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

parent string

The name of the Document where this batch of Chunks will be created. Example: corpora/my-corpus-123/documents/the-doc-abc

requests List<CreateChunkRequest>

The request messages specifying the Chunks to create. A maximum of 100 Chunks can be created in a batch.

cancellationToken CancellationToken

A 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

parent string

The name of the Document containing the Chunks to delete. Example: corpora/my-corpus-123/documents/the-doc-abc

requests List<DeleteChunkRequest>

The request messages specifying the Chunks to delete.

cancellationToken CancellationToken

A 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

parent string

The name of the Document containing the Chunks to update. Example: corpora/my-corpus-123/documents/the-doc-abc

requests List<UpdateChunkRequest>

The request messages specifying the Chunks to update. A maximum of 100 Chunks can be updated in a batch.

cancellationToken CancellationToken

A 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

parent string

The name of the Document where this Chunk will be created. Example: corpora/my-corpus-123/documents/the-doc-abc

chunk Chunk

The Chunk to create.

cancellationToken CancellationToken

A cancellation token to cancel the request.

Returns

Task<Chunk>

The created Chunk.

See Also

DeleteChunkAsync(string, CancellationToken)

Deletes a Chunk resource.

public Task DeleteChunkAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string

The resource name of the Chunk to delete. Example: corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk

cancellationToken CancellationToken

A 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

name string

The resource name of the Chunk to retrieve. Example: corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk

cancellationToken CancellationToken

A cancellation token to cancel the request.

Returns

Task<Chunk>

The Chunk resource.

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

parent string

The name of the Document containing Chunks. Example: corpora/my-corpus-123/documents/the-doc-abc

pageSize int?

The maximum number of Chunk resources to return.

pageToken string

A page token, received from a previous ListChunksAsync(string, int?, string?, CancellationToken) call.

cancellationToken CancellationToken

A 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

chunk Chunk

The Chunk resource to update.

updateMask string

The list of fields to update. Currently, this only supports updating customMetadata and data.

cancellationToken CancellationToken

A cancellation token to cancel the request.

Returns

Task<Chunk>

The updated Chunk resource.

See Also

See Also