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
platformIPlatformAdapterhttpClientHttpClientloggerILogger
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
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
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
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
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
operationIdstringThe unique identifier of the long-running operation to monitor.
timeOutint?Optional timeout (in milliseconds) for awaiting the operation. If not provided, the default timeout specified by LongRunningOperationTimeout is used.
cancellationTokenCancellationTokenAn 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
corpusRagCorpusThe RagCorpus instance representing the corpus configuration to be created.
cancellationTokenCancellationTokenOptional 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
displayNamestringThe display name of the corpus to be created.
descriptionstringA brief description of the corpus being created.
pineconeConfigRagVectorDbConfigPineconeThe configuration for the Pinecone vector database to be associated with the corpus.
apiKeyResourceNamestringThis 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}embeddingModelNamestringThe name of the embedding model to be used for the corpus. If not provided, Vertex AI's default embedding model is used.
cancellationTokenCancellationTokenA 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
displayNamestringThe display name for the new corpus.
descriptionstringAn optional description of the corpus to provide additional context.
vertexFeatureStoreConfigRagVectorDbConfigVertexFeatureStoreThe configuration details for the Vertex feature store to be associated with the corpus.
embeddingModelNamestringThe embedding model's name to be used for the corpus, If not provided, Vertex AI's default embedding model is used.
cancellationTokenCancellationTokenAn 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
displayNamestringThe display name of the RAG corpus to be created.
descriptionstringAn optional description of the RAG corpus to provide additional context or details.
vertexSearchStoreConfigRagVectorDbConfigVertexVectorSearchThe configuration parameters for the Vertex feature store to associate with the new corpus.
embeddingModelNamestringThe name of the embedding model to use with the corpus. If not provided, Vertex AI's default embedding model is used.
cancellationTokenCancellationTokenAn 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
displayNamestringThe display name of the corpus to be created.
descriptionstringA brief description of the corpus being created.
weaviateConfigRagVectorDbConfigWeaviateThe configuration for the Weaviate vector database to be associated with the corpus.
apiKeyResourceNamestringThe 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}
embeddingModelNamestringThe name of the embedding model to be used for the corpus. If not provided, Vertex AI's default embedding model is used.
cancellationTokenCancellationTokenA 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
displayNamestringThe display name of the corpus to be created.
descriptionstringA brief description of the corpus being created.
embeddingModelNamestringThe name of the embedding model to be used for the corpus. If not provided, Vertex AI's default embedding model is used.
cancellationTokenCancellationTokenA 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
fileIdstringThe unique identifier of the RAG file to be deleted.
cancellationTokenCancellationTokenA 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
namestringThe resource name of the RagCorpus to delete.
cancellationTokenCancellationTokenThe 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
namestringThe resource name of the RagCorpus.
cancellationTokenCancellationTokenThe cancellation token to cancel the operation.
Returns
- 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
cancellationTokenCancellationTokenAn 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
fileIdstringThe unique identifier of the RAG file to retrieve.
cancellationTokenCancellationTokenA 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
corpusNamestringThe name of the RAG corpus where the files are to be imported.
sourceGcsSourceThe Google Cloud Storage (GCS) source containing the files to be imported.
parsingConfigRagFileParsingConfigOptional configuration to define how the files should be parsed upon import.
transformationConfigRagFileTransformationConfigOptional configuration to define how the files should be transformed during the import process.
cancellationTokenCancellationTokenToken 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
corpusNamestringThe name of the RAG corpus where the files are to be imported.
googleDriveSourceGoogleDriveSourceThe Google Drive source from which the files will be imported.
parsingConfigRagFileParsingConfigOptional configuration specifying how the files should be parsed.
transformationConfigRagFileTransformationConfigOptional configuration specifying how the files should be transformed during the import process.
cancellationTokenCancellationTokenToken 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
corpusNamestringThe name of the corpus to which the files will be imported.
requestImportRagFilesRequestAn instance of ImportRagFilesRequest containing the details of files to import.
cancellationTokenCancellationTokenAn 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
corpusNamestringThe name of the RAG corpus into which the files will be imported.
jiraSourceJiraSourceThe Jira source containing the files to be imported into the RAG corpus.
parsingConfigRagFileParsingConfigOptional configuration for parsing the files during the import process.
transformationConfigRagFileTransformationConfigOptional configuration for applying transformations to the files during the import process.
cancellationTokenCancellationTokenA 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
corpusNamestringThe name of the RAG corpus into which the files will be imported.
sharePointSourcesSharePointSourcesThe SharePoint source containing the files to be imported into the RAG corpus.
parsingConfigRagFileParsingConfigOptional configuration for parsing the files during the import process.
transformationConfigRagFileTransformationConfigOptional configuration for applying transformations to the files during the import process.
cancellationTokenCancellationTokenA 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
corpusNamestringThe name of the RAG corpus into which the files will be imported.
slackSourceSlackSourceThe Slack source containing the files to be imported into the RAG corpus.
parsingConfigRagFileParsingConfigOptional configuration for parsing the files during the import process.
transformationConfigRagFileTransformationConfigOptional configuration for applying transformations to the files during the import process.
cancellationTokenCancellationTokenA 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
pageSizeint?The maximum number of RagCorpus resources to return.
pageTokenstringA page token, received from a previous ListCorporaAsync(int?, string?, CancellationToken) call.
cancellationTokenCancellationTokenThe 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
corpusIdstringThe unique identifier of the corpus containing the RAG files.
pageSizeint?The desired number of files to retrieve per page. If null, the default server-defined page size is used.
pageTokenstringThe token for continuing the listing from a specific point in the pagination.
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenAn 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
corpusRagCorpusThe RagCorpus object containing the updated information for the RAG corpus.
cancellationTokenCancellationTokenA 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
configRagEngineConfigThe new configuration, for example
new RagEngineConfig { RagManagedDbConfig = RagManagedDbConfig.CreateServerless() }.cancellationTokenCancellationTokenAn 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
corpusNamestringThe name of the RAG corpus to upload the file to.
localFilePathstringThe full path to the local file to be uploaded.
displayNamestringA user-friendly name for the uploaded file.
descriptionstringAn optional description of the file being uploaded.
uploadRagFileConfigUploadRagFileConfigOptional configuration settings for uploading the RAG file.
progressCallbackAction<double>An optional callback to monitor the upload progress, represented as a percentage value.
cancellationTokenCancellationTokenA token to monitor and handle request cancellation.
Returns
- Task<RagFile>
An UploadRagFileResponse containing details about the uploaded file, or null if the operation fails.