Class DocumentsClient
- Namespace
- GenerativeAI.Clients
- Assembly
- GenerativeAI.dll
A client for interacting with the Documents API.
public class DocumentsClient : BaseClient
- Inheritance
-
DocumentsClient
- Inherited Members
- Extension Methods
Constructors
DocumentsClient(IPlatformAdapter, HttpClient?, ILogger?)
A client for interacting with the Documents API. Provides methods to create, query, list, retrieve, update, and delete document resources.
public DocumentsClient(IPlatformAdapter platform, HttpClient? httpClient = null, ILogger? logger = null)
Parameters
platformIPlatformAdapterhttpClientHttpClientloggerILogger
Remarks
This client simplifies interaction with the backend endpoint handling document-related operations.
- 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.
CreateDocumentAsync(string, Document, CancellationToken)
Creates a new Document resource.
public Task<Document?> CreateDocumentAsync(string parent, Document document, CancellationToken cancellationToken = default)
Parameters
parentstringThe name of the Corpus where this Document will be created. Required.
documentDocumentThe Document to create.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- See Also
DeleteDocumentAsync(string, bool?, CancellationToken)
Deletes a Document resource.
public Task DeleteDocumentAsync(string name, bool? force = null, CancellationToken cancellationToken = default)
Parameters
namestringThe resource name of the Document to delete. Required.
forcebool?If set to true, any Chunk resources and objects related to this Document will also be deleted. Optional.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- Task
A task representing the asynchronous operation.
- See Also
GetDocumentAsync(string, CancellationToken)
Gets information about a specific Document resource.
public Task<Document?> GetDocumentAsync(string name, CancellationToken cancellationToken = default)
Parameters
namestringThe name of the Document to retrieve. Required.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- See Also
ListDocumentsAsync(string, int?, string?, CancellationToken)
public Task<ListDocumentsResponse?> ListDocumentsAsync(string parent, int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)
Parameters
parentstringThe name of the Corpus containing Document resources. Required.
pageSizeint?The maximum number of Document resources to return (per page). Optional.
pageTokenstringA page token, received from a previous ListDocumentsAsync(string, int?, string?, CancellationToken) call. Optional.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- Task<ListDocumentsResponse>
A list of Document resources.
- See Also
QueryDocumentAsync(string, QueryDocumentRequest, CancellationToken)
Performs semantic search over a Document.
public Task<QueryDocumentResponse?> QueryDocumentAsync(string name, QueryDocumentRequest queryDocumentRequest, CancellationToken cancellationToken = default)
Parameters
namestringThe name of the Document to query. Required.
queryDocumentRequestQueryDocumentRequestThe query parameters.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- Task<QueryDocumentResponse>
A list of RelevantChunk resources.
- See Also
UpdateDocumentAsync(string, Document, string, CancellationToken)
Updates a Document resource.
public Task<Document?> UpdateDocumentAsync(string name, Document document, string updateMask, CancellationToken cancellationToken = default)
Parameters
namestringThe resource name of the Document.
documentDocumentThe Document resource to update.
updateMaskstringThe list of fields to update. Required.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- See Also