Table of Contents

Class VertexRagManager

Namespace
GenerativeAI.Types.RagEngine
Assembly
GenerativeAI.dll

VertexRagManager provides management and interaction capabilities for RAG (Retrieval-Augmented Generation) resources. It is designed to facilitate operations involving file management and RAG corpus resources. This class serves as a specialized client built upon the BaseClient, leveraging shared functionality like authorization handling and HTTP communication. The manager provides direct access to:

  • File management operations via FileManagementClient.
  • RAG corpus operations via RagCorpusClient.
public class VertexRagManager : BaseClient
Inheritance
VertexRagManager
Inherited Members
Extension Methods

Constructors

VertexRagManager(IPlatformAdapter, HttpClient?, ILogger?)

VertexRagManager provides management and interaction capabilities for RAG (Retrieval-Augmented Generation) resources. It is designed to facilitate operations involving file management and RAG corpus resources.

public VertexRagManager(IPlatformAdapter platform, HttpClient? httpClient, ILogger? logger = null)

Parameters

platform IPlatformAdapter
httpClient HttpClient
logger ILogger

Remarks

Inherits functionality from BaseClient, leveraging its shared features such as authorization handling and HTTP communication. The VertexRagManager provides:

  • File management operations via the FileManager property.
  • RAG corpus operations via the RagCorpus property.

Properties

FileManager

Provides access to file management operations within the VertexRagManager context. This property is an instance of the FileManagementClient class and enables methods for uploading, importing, listing, retrieving, and deleting RAG (Retrieval-Augmented Generation) files. These operations are essential for managing file resources in RAG-based workflows.

public FileManagementClient FileManager { get; }

Property Value

FileManagementClient

LongRunningOperationTimeout

Specifies the timeout duration, in milliseconds, for long-running operations initiated within the VertexRagManager. This property determines the maximum amount of time that the system will wait for such operations to complete before considering them as timed out.

public int LongRunningOperationTimeout { get; set; }

Property Value

int

OperationsClient

Provides access to manage long-running operations within the VertexRagManager context. This property is an instance of the OperationsClient class and facilitates tracking, retrieving, and controlling asynchronous operations performed by the manager.

public OperationsClient OperationsClient { get; }

Property Value

OperationsClient

RagCorpusClient

Provides access to RAG (Retrieval-Augmented Generation) corpus management operations within the VertexRagManager context. This property is an instance of the RagCorpusClient class. It enables creating, listing, retrieving, updating, and deleting RAG corpus resources. These capabilities are crucial for managing data corpora used in generation and retrieval workflows.

public RagCorpusClient RagCorpusClient { get; }

Property Value

RagCorpusClient

Methods

AwaitForLongRunningOperation(string, int?, CancellationToken)

Awaits the completion of a long-running operation specified by its operation ID. This method repeatedly checks the operation's progress until it's complete or until the specified timeout is reached.

public Task<GoogleLongRunningOperation?> AwaitForLongRunningOperation(string operationId, int? timeOut = null, CancellationToken cancellationToken = default)

Parameters

operationId string

The unique identifier of the long-running operation to monitor.

timeOut int?

Optional timeout (in milliseconds) for awaiting the operation. If not provided, the default timeout specified by LongRunningOperationTimeout is used.

cancellationToken CancellationToken

An optional token to observe and respond to cancellation requests.

Returns

Task<GoogleLongRunningOperation>

Returns a GoogleLongRunningOperation instance representing the final state of the long-running operation upon completion. Throws an exception if the operation encounters an error.

CreateCorpusAsync(RagCorpus, CancellationToken)

Asynchronously creates a new RAG corpus and returns the resulting RagCorpus object upon completion.

public Task<RagCorpus?> CreateCorpusAsync(RagCorpus corpus, CancellationToken cancellationToken = default)

Parameters

corpus RagCorpus

The RagCorpus instance representing the corpus configuration to be created.

cancellationToken CancellationToken

Optional token to monitor for cancellation requests.

Returns

Task<RagCorpus>

A task that represents the asynchronous operation. The task result contains the created RagCorpus, or null if the operation fails or cannot determine the result.

CreateCorpusAsync(string, string?, RagVectorDbConfigPinecone, string, string?, CancellationToken)

creates a new RAG (Retrieval-Augmented Generation) corpus with the specified parameters.

public Task<RagCorpus?> CreateCorpusAsync(string displayName, string? description, RagVectorDbConfigPinecone pineconeConfig, string apiKeyResourceName, string? embeddingModelName = null, CancellationToken cancellationToken = default)

Parameters

displayName string

The display name of the corpus to be created.

description string

A brief description of the corpus being created.

pineconeConfig RagVectorDbConfigPinecone

The configuration for the Pinecone vector database to be associated with the corpus.

apiKeyResourceName string

This the full resource name of the secret that is stored in Secret Manager, which contains your Weaviate or Pinecone API key that depends on your choice of vector database.
Format: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

embeddingModelName string

The name of the embedding model to be used for the corpus. If not provided, Vertex AI's default embedding model is used.

cancellationToken CancellationToken

A token to cancel the operation, if needed. Defaults to None.

Returns

Task<RagCorpus>

A Task representing the asynchronous operation, containing the created RagCorpus instance.

CreateCorpusAsync(string, string?, RagVectorDbConfigVertexFeatureStore, string?, CancellationToken)

Asynchronously creates a new RAG (Retrieval-Augmented Generation) corpus with the provided parameters and configuration.

public Task<RagCorpus?> CreateCorpusAsync(string displayName, string? description, RagVectorDbConfigVertexFeatureStore vertexFeatureStoreConfig, string? embeddingModelName = null, CancellationToken cancellationToken = default)

Parameters

displayName string

The display name for the new corpus.

description string

An optional description of the corpus to provide additional context.

vertexFeatureStoreConfig RagVectorDbConfigVertexFeatureStore

The configuration details for the Vertex feature store to be associated with the corpus.

embeddingModelName string

The embedding model's name to be used for the corpus, If not provided, Vertex AI's default embedding model is used.

cancellationToken CancellationToken

An optional token to cancel the operation before completion. Defaults to None.

Returns

Task<RagCorpus>

A Task that represents the asynchronous operation and returns the created RagCorpus instance, or null if the operation fails.

CreateCorpusAsync(string, string?, RagVectorDbConfigVertexVectorSearch, string?, CancellationToken)

Asynchronously creates a new RAG (Retrieval-Augmented Generation) corpus with the specified parameters and configurations.

public Task<RagCorpus?> CreateCorpusAsync(string displayName, string? description, RagVectorDbConfigVertexVectorSearch vertexSearchStoreConfig, string? embeddingModelName = null, CancellationToken cancellationToken = default)

Parameters

displayName string

The display name of the RAG corpus to be created.

description string

An optional description of the RAG corpus to provide additional context or details.

vertexSearchStoreConfig RagVectorDbConfigVertexVectorSearch

The configuration parameters for the Vertex feature store to associate with the new corpus.

embeddingModelName string

The name of the embedding model to use with the corpus. If not provided, Vertex AI's default embedding model is used.

cancellationToken CancellationToken

An optional token to cancel the operation. Defaults to None if not specified.

Returns

Task<RagCorpus>

A Task representing the asynchronous operation, containing the created RagCorpus instance, or null if the operation fails.

CreateCorpusAsync(string, string?, RagVectorDbConfigWeaviate, string, string?, CancellationToken)

Creates a new RAG (Retrieval-Augmented Generation) corpus with the specified parameters.

public Task<RagCorpus?> CreateCorpusAsync(string displayName, string? description, RagVectorDbConfigWeaviate weaviateConfig, string apiKeyResourceName, string? embeddingModelName = null, CancellationToken cancellationToken = default)

Parameters

displayName string

The display name of the corpus to be created.

description string

A brief description of the corpus being created.

weaviateConfig RagVectorDbConfigWeaviate

The configuration for the Weaviate vector database to be associated with the corpus.

apiKeyResourceName string

The full resource name of the secret stored in Secret Manager, which contains the API key for the vector database. Format: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

embeddingModelName string

The name of the embedding model to be used for the corpus. If not provided, Vertex AI's default embedding model is used.

cancellationToken CancellationToken

A token to cancel the operation, if needed. Defaults to None.

Returns

Task<RagCorpus>

A Task representing the asynchronous operation, containing the created RagCorpus instance.

CreateCorpusAsync(string, string?, string?, CancellationToken)

Creates a new RAG (Retrieval-Augmented Generation) corpus with the specified parameters.

public Task<RagCorpus?> CreateCorpusAsync(string displayName, string? description, string? embeddingModelName = null, CancellationToken cancellationToken = default)

Parameters

displayName string

The display name of the corpus to be created.

description string

A brief description of the corpus being created.

embeddingModelName string

The name of the embedding model to be used for the corpus. If not provided, Vertex AI's default embedding model is used.

cancellationToken CancellationToken

A token to cancel the operation, if needed. Defaults to None.

Returns

Task<RagCorpus>

A Task representing the asynchronous operation, containing the created RagCorpus instance.

DeleteFileAsync(string, CancellationToken)

Deletes a specified RAG (Retrieval-Augmented Generation) file by its unique file identifier.

public Task DeleteFileAsync(string fileId, CancellationToken cancellationToken = default)

Parameters

fileId string

The unique identifier of the RAG file to be deleted.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task

A task representing the asynchronous operation. No value is returned upon completion.

DeleteRagCorpusAsync(string, CancellationToken)

Deletes a RagCorpus resource.

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

Parameters

name string

The resource name of the RagCorpus to delete.

cancellationToken CancellationToken

The cancellation token to cancel the operation.

Returns

Task

A task representing the asynchronous operation.

See Also

GetCorpusAsync(string, CancellationToken)

Gets a specific RagCorpus resource.

public Task<RagCorpus?> GetCorpusAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string

The resource name of the RagCorpus.

cancellationToken CancellationToken

The cancellation token to cancel the operation.

Returns

Task<RagCorpus>

The RagCorpus resource.

See Also

GetEngineConfigAsync(CancellationToken)

Gets the RAG Engine configuration (Serverless or Spanner mode) for the platform's location.

public Task<RagEngineConfig?> GetEngineConfigAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

An optional token to observe and respond to cancellation requests.

Returns

Task<RagEngineConfig>

The current RagEngineConfig.

GetFileAsync(string, CancellationToken)

Retrieves a specified RAG file by its unique file identifier.

public Task<RagFile?> GetFileAsync(string fileId, CancellationToken cancellationToken = default)

Parameters

fileId string

The unique identifier of the RAG file to retrieve.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<RagFile>

A RagFile instance representing the requested RAG file, or null if the file is not found.

ImportFilesAsync(string, GcsSource, RagFileParsingConfig?, RagFileTransformationConfig?, CancellationToken)

Imports files into a specified RAG corpus using Google Cloud Storage (GCS) as a source, with optional parsing and transformation configurations.

public Task<GoogleLongRunningOperation?> ImportFilesAsync(string corpusName, GcsSource source, RagFileParsingConfig? parsingConfig = null, RagFileTransformationConfig? transformationConfig = null, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the RAG corpus where the files are to be imported.

source GcsSource

The Google Cloud Storage (GCS) source containing the files to be imported.

parsingConfig RagFileParsingConfig

Optional configuration to define how the files should be parsed upon import.

transformationConfig RagFileTransformationConfig

Optional configuration to define how the files should be transformed during the import process.

cancellationToken CancellationToken

Token to monitor and handle request cancellation.

Returns

Task<GoogleLongRunningOperation>

An asynchronous operation of type GoogleLongRunningOperation representing the import process.

ImportFilesAsync(string, GoogleDriveSource, RagFileParsingConfig?, RagFileTransformationConfig?, CancellationToken)

Imports files from a Google Drive source to a specified RAG corpus with optional configurations for parsing and transformation.

public Task<GoogleLongRunningOperation?> ImportFilesAsync(string corpusName, GoogleDriveSource googleDriveSource, RagFileParsingConfig? parsingConfig = null, RagFileTransformationConfig? transformationConfig = null, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the RAG corpus where the files are to be imported.

googleDriveSource GoogleDriveSource

The Google Drive source from which the files will be imported.

parsingConfig RagFileParsingConfig

Optional configuration specifying how the files should be parsed.

transformationConfig RagFileTransformationConfig

Optional configuration specifying how the files should be transformed during the import process.

cancellationToken CancellationToken

Token to monitor and respond to cancellation requests for the import operation.

Returns

Task<GoogleLongRunningOperation>

An asynchronous operation of type GoogleLongRunningOperation representing the status of the import process.

ImportFilesAsync(string, ImportRagFilesRequest, CancellationToken)

Asynchronously imports files to a specified RAG corpus using the provided request details.

public Task<GoogleLongRunningOperation?> ImportFilesAsync(string corpusName, ImportRagFilesRequest request, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the corpus to which the files will be imported.

request ImportRagFilesRequest

An instance of ImportRagFilesRequest containing the details of files to import.

cancellationToken CancellationToken

An optional token to cancel the operation, if necessary.

Returns

Task<GoogleLongRunningOperation>

A GoogleLongRunningOperation instance that represents the long-running import operation.

ImportFilesAsync(string, JiraSource, RagFileParsingConfig?, RagFileTransformationConfig?, CancellationToken)

Asynchronously imports files into a specified Retrieval-Augmented Generation (RAG) corpus from a Jira source, with optional parsing and transformation configurations.

public Task<GoogleLongRunningOperation?> ImportFilesAsync(string corpusName, JiraSource jiraSource, RagFileParsingConfig? parsingConfig = null, RagFileTransformationConfig? transformationConfig = null, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the RAG corpus into which the files will be imported.

jiraSource JiraSource

The Jira source containing the files to be imported into the RAG corpus.

parsingConfig RagFileParsingConfig

Optional configuration for parsing the files during the import process.

transformationConfig RagFileTransformationConfig

Optional configuration for applying transformations to the files during the import process.

cancellationToken CancellationToken

A token that allows the operation to be canceled.

Returns

Task<GoogleLongRunningOperation>

An instance of GoogleLongRunningOperation that represents the ongoing asynchronous import operation.

ImportFilesAsync(string, SharePointSources, RagFileParsingConfig?, RagFileTransformationConfig?, CancellationToken)

Asynchronously imports files into a specified Retrieval-Augmented Generation (RAG) corpus from a SharePoint source, with optional parsing and transformation configurations.

public Task<GoogleLongRunningOperation?> ImportFilesAsync(string corpusName, SharePointSources sharePointSources, RagFileParsingConfig? parsingConfig = null, RagFileTransformationConfig? transformationConfig = null, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the RAG corpus into which the files will be imported.

sharePointSources SharePointSources

The SharePoint source containing the files to be imported into the RAG corpus.

parsingConfig RagFileParsingConfig

Optional configuration for parsing the files during the import process.

transformationConfig RagFileTransformationConfig

Optional configuration for applying transformations to the files during the import process.

cancellationToken CancellationToken

A token that allows the operation to be canceled.

Returns

Task<GoogleLongRunningOperation>

An instance of GoogleLongRunningOperation that represents the ongoing asynchronous import operation.

ImportFilesAsync(string, SlackSource, RagFileParsingConfig?, RagFileTransformationConfig?, CancellationToken)

Asynchronously imports files into a specified Retrieval-Augmented Generation (RAG) corpus from a Slack source, with optional parsing and transformation configurations.

public Task<GoogleLongRunningOperation?> ImportFilesAsync(string corpusName, SlackSource slackSource, RagFileParsingConfig? parsingConfig = null, RagFileTransformationConfig? transformationConfig = null, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the RAG corpus into which the files will be imported.

slackSource SlackSource

The Slack source containing the files to be imported into the RAG corpus.

parsingConfig RagFileParsingConfig

Optional configuration for parsing the files during the import process.

transformationConfig RagFileTransformationConfig

Optional configuration for applying transformations to the files during the import process.

cancellationToken CancellationToken

A token that allows the operation to be canceled.

Returns

Task<GoogleLongRunningOperation>

An instance of GoogleLongRunningOperation that represents the ongoing asynchronous import operation.

ListCorporaAsync(int?, string?, CancellationToken)

Lists available RagCorpus resources.

public Task<ListRagCorporaResponse?> ListCorporaAsync(int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)

Parameters

pageSize int?

The maximum number of RagCorpus resources to return.

pageToken string

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

cancellationToken CancellationToken

The cancellation token to cancel the operation.

Returns

Task<ListRagCorporaResponse>

A list of RagCorpus resources.

See Also

ListFilesAsync(string, int?, string?, CancellationToken)

Retrieves a paginated list of RAG (Retrieval-Augmented Generation) files within the specified corpus.

public Task<ListRagFilesResponse?> ListFilesAsync(string corpusId, int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)

Parameters

corpusId string

The unique identifier of the corpus containing the RAG files.

pageSize int?

The desired number of files to retrieve per page. If null, the default server-defined page size is used.

pageToken string

The token for continuing the listing from a specific point in the pagination.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<ListRagFilesResponse>

A ListRagFilesResponse object containing the list of RAG files and pagination details, or null if no files are found.

SwitchToServerlessModeAsync(CancellationToken)

Switches the RAG Engine for the platform's location to Serverless mode and waits for the change to complete.

public Task<RagEngineConfig?> SwitchToServerlessModeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

An optional token to observe and respond to cancellation requests.

Returns

Task<RagEngineConfig>

The updated RagEngineConfig.

UpdateCorpusAsync(RagCorpus, CancellationToken)

Updates an existing RAG corpus asynchronously.

public Task<RagCorpus> UpdateCorpusAsync(RagCorpus corpus, CancellationToken cancellationToken = default)

Parameters

corpus RagCorpus

The RagCorpus object containing the updated information for the RAG corpus.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<RagCorpus>

The updated RagCorpus object if the operation is successful, or null if the operation fails.

Remarks

This method updates an existing RAG corpus by sending the desired modifications, waits for the long-running operation to complete, and retrieves the updated corpus upon completion.

UpdateEngineConfigAsync(RagEngineConfig, CancellationToken)

Updates the RAG Engine configuration for the platform's location and waits for the change to complete.

public Task<RagEngineConfig?> UpdateEngineConfigAsync(RagEngineConfig config, CancellationToken cancellationToken = default)

Parameters

config RagEngineConfig

The new configuration, for example new RagEngineConfig { RagManagedDbConfig = RagManagedDbConfig.CreateServerless() }.

cancellationToken CancellationToken

An optional token to observe and respond to cancellation requests.

Returns

Task<RagEngineConfig>

The updated RagEngineConfig.

Remarks

Choosing Unprovisioned disables the RAG Engine and permanently deletes its data.

UploadLocalFileAsync(string, string, string?, string?, UploadRagFileConfig?, Action<double>?, CancellationToken)

Uploads a local file to the specified RAG corpus with optional progress tracking and metadata.

public Task<RagFile?> UploadLocalFileAsync(string corpusName, string localFilePath, string? displayName = null, string? description = null, UploadRagFileConfig? uploadRagFileConfig = null, Action<double>? progressCallback = null, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the RAG corpus to upload the file to.

localFilePath string

The full path to the local file to be uploaded.

displayName string

A user-friendly name for the uploaded file.

description string

An optional description of the file being uploaded.

uploadRagFileConfig UploadRagFileConfig

Optional configuration settings for uploading the RAG file.

progressCallback Action<double>

An optional callback to monitor the upload progress, represented as a percentage value.

cancellationToken CancellationToken

A token to monitor and handle request cancellation.

Returns

Task<RagFile>

An UploadRagFileResponse containing details about the uploaded file, or null if the operation fails.