Table of Contents

Interface IGenerativeAI

Namespace
GenerativeAI
Assembly
GenerativeAI.dll

Represents an interface defining operations for generative AI systems, including initializing models, retrieving model details, listing available models, and accessing platform-specific adapters.

public interface IGenerativeAI
Extension Methods

Methods

CreateEmbeddingModel(string)

Creates and initializes an embedding model for use in embedding-related AI tasks. The created model is configured with the provided model name and integrates with the underlying platform adapter.

EmbeddingModel CreateEmbeddingModel(string modelName)

Parameters

modelName string

The name of the embedding model to initialize, used to identify the specific AI model for embeddings.

Returns

EmbeddingModel

An instance of EmbeddingModel initialized with the specified model name and platform configurations.

CreateGenerativeModel(string, GenerationConfig?, ICollection<SafetySetting>?, string?)

Creates and initializes a generative model capable of producing AI-generated content. The model is configured with the specified parameters to customize its behavior and ensure safety compliance when generating content.

GenerativeModel CreateGenerativeModel(string modelName, GenerationConfig? config = null, ICollection<SafetySetting>? safetyRatings = null, string? systemInstruction = null)

Parameters

modelName string

The name of the generative model to initialize, used to identify the specific AI model for content generation.

config GenerationConfig

Optional parameter specifying the generation configuration, such as temperature, max tokens, or other customization options.

safetyRatings ICollection<SafetySetting>

Optional collection of safety settings used to enforce content safety thresholds during generation.

systemInstruction string

Optional system-level instruction guiding the behavior of the generative model.

Returns

GenerativeModel

An instance of GenerativeModel configured with the specified parameters for generative tasks.

GetModelAsync(string, CancellationToken)

Retrieves a specific AI model by its name asynchronously from the Google's AI platform.

Task<Model> GetModelAsync(string modelName, CancellationToken cancellationToken = default)

Parameters

modelName string

The unique name of the model to retrieve.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<Model>

A task representing the asynchronous operation, containing the requested model details as a Model object.

GetPlatformAdapter()

Retrieves the platform adapter responsible for handling platform-specific operations such as authentication, API versioning, and URL construction. The platform adapter ensures seamless integration with the underlying platform by managing necessary credentials and configurations.

IPlatformAdapter GetPlatformAdapter()

Returns

IPlatformAdapter

An instance of IPlatformAdapter that provides methods for platform-specific functionality.

ListModelsAsync(int?, string?, CancellationToken)

Asynchronously retrieves a list of AI models available in Google's AI platform. This method supports pagination to fetch models in batches using the specified page size and page token, enabling efficient handling of large model datasets.

Task<ListModelsResponse> ListModelsAsync(int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)

Parameters

pageSize int?

Optional parameter specifying the maximum number of models to retrieve per page. Defaults to null for the API's standard page size.

pageToken string

Optional parameter indicating the token for the next page of results, as provided in a previous response.

cancellationToken CancellationToken

Optional parameter for propagating cancellation signals, allowing the operation to be canceled if needed.

Returns

Task<ListModelsResponse>

A task representing the asynchronous operation, which contains a ListModelsResponse with the retrieved models and pagination details.