Interface IPlatformAdapter
- Namespace
- GenerativeAI.Core
- Assembly
- GenerativeAI.dll
Defines an interface for platform-specific operations required to integrate with external APIs.
public interface IPlatformAdapter
- Extension Methods
Properties
Authenticator
Gets or sets the authenticator responsible for managing authentication processes with Google services.
IGoogleAuthenticator? Authenticator { get; set; }
Property Value
Remarks
This property is used to handle authentication tasks, such as obtaining and refreshing access tokens, that are necessary to interact with Google APIs.
Methods
AddAuthorizationAsync(HttpRequestMessage, bool, CancellationToken)
Adds the necessary authorization headers to the given HTTP request.
Task AddAuthorizationAsync(HttpRequestMessage request, bool requireAccessToken, CancellationToken cancellationToken = default)
Parameters
requestHttpRequestMessageThe HTTP request to which authorization headers will be added.
requireAccessTokenboolSpecifies whether an access token is required for the request.
cancellationTokenCancellationTokenThe cancellation token to cancel the operation.
Returns
- Task
A task that represents the asynchronous operation.
AuthorizeAsync(CancellationToken)
Authorizes the user by acquiring necessary tokens or credentials.
Task AuthorizeAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token to cancel the operation.
Returns
- Task
A task that represents the asynchronous operation.
CreateUrlForModel(string, string)
Constructs a URL for a specific AI model operation.
string CreateUrlForModel(string modelId, string task)
Parameters
modelIdstringThe unique identifier of the model.
taskstringThe specific task for the model (e.g., training or evaluation).
Returns
- string
The constructed URL as a string.
CreateUrlForTunedModel(string, string)
Constructs a URL for operations involving a fine-tuned model.
string CreateUrlForTunedModel(string modelId, string task)
Parameters
modelIdstringThe unique identifier of the fine-tuned model.
taskstringThe specific task involving the fine-tuned model.
Returns
- string
The constructed URL as a string.
GetAccessTokenAsync(CancellationToken)
Retrieves the access token required for making authenticated API requests.
Task<AuthTokens?> GetAccessTokenAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token to cancel the operation if needed.
Returns
- Task<AuthTokens>
A task that represents the asynchronous operation, containing the authentication tokens.
GetApiVersion()
Retrieves the current API version used by the platform.
string GetApiVersion()
Returns
- string
The API version as a string.
GetApiVersionForFile()
Retrieves the API version related to file operations.
string GetApiVersionForFile()
Returns
- string
The API version for file operations.
GetBaseUrl(bool, bool, bool, bool)
Retrieves the base URL of the platform's API.
string GetBaseUrl(bool appendVersion = true, bool appendPublisher = true, bool appendLocation = true, bool appendProject = true)
Parameters
appendVersionboolDetermines whether to append the API version to the URL.
appendPublisherboolDetermines whether to append the publisher identifier to the URL.
appendLocationboolappendProjectbool
Returns
- string
The base URL as a string.
GetBaseUrlForFile()
Retrieves the base URL for file-related API operations.
string GetBaseUrlForFile()
Returns
- string
The base URL for file operations as a string.
GetFullyQualifiedModelName(string, bool)
Gets the formatted model name for multi-modal live sessions.
string? GetFullyQualifiedModelName(string modelName, bool appendLocation = true)
Parameters
modelNamestringThe base model name to format.
appendLocationboolWhether to include the location segment in the qualified name.
Returns
- string
The formatted model name for multi-modal live sessions, or null if not applicable.
GetMultiModalLiveUrl(string)
Gets the WebSocket URL for multi-modal live sessions.
string GetMultiModalLiveUrl(string version = "v1alpha")
Parameters
versionstringThe API version to use (default: "v1alpha").
Returns
- string
The WebSocket URL for multi-modal live sessions.
SetAuthenticator(IGoogleAuthenticator)
Sets the Google authenticator responsible for managing authentication processes for Google services.
void SetAuthenticator(IGoogleAuthenticator authenticator)
Parameters
authenticatorIGoogleAuthenticatorThe Google authenticator to be used for handling authentication operations.
ValidateCredentialsAsync(CancellationToken)
Validates user credentials before making API requests.
Task ValidateCredentialsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token to cancel the operation.
Returns
- Task
A task that represents the asynchronous operation.