Table of Contents

Class GoogleAi

Namespace
GenerativeAI
Assembly
GenerativeAI.dll

The GoogleAI class serves as the main entry point for interacting with Google's AI models. It provides methods to create generative and embedding models, as well as manage and retrieve model details. This class integrates Google's AI platform capabilities by utilizing appropriate models and configurations to handle generative AI tasks, embeddings, and other related operations.

public class GoogleAi : GenAI, IGenerativeAI
Inheritance
GoogleAi
Implements
Inherited Members
Extension Methods

Constructors

GoogleAi(IPlatformAdapter, HttpClient?, ILogger?)

Represents a specific implementation of the GenAI base class designed for Google's AI platform. Offers functionality to interact with Google's generative AI and machine learning models. Provides support for initialization with various parameters such as API keys, access tokens, HTTP client, and logging.

public GoogleAi(IPlatformAdapter adapter, HttpClient? client = null, ILogger? logger = null)

Parameters

adapter IPlatformAdapter
client HttpClient
logger ILogger

GoogleAi(string?, string?, HttpClient?, ILogger?)

Implements a client adapter for Google's AI platform to facilitate integration with its generative AI services. Provides configuration and methods for managing credentials, setting API versions, creating task URLs, and authorizing requests for secure access to Google's AI APIs.

public GoogleAi(string? apiKey = null, string? accessToken = null, HttpClient? client = null, ILogger? logger = null)

Parameters

apiKey string
accessToken string
client HttpClient
logger ILogger

Methods

CreatSemanticRetrieverModel(string, ICollection<SafetySetting>?, IGoogleAuthenticator?)

Creates and initializes an instance of the SemanticRetrieverModel. This model is designed to interact with Google's semantic retrieval services. It requires a valid Google authenticator for secure access and supports optional safety settings for content moderation.

public SemanticRetrieverModel CreatSemanticRetrieverModel(string modelName, ICollection<SafetySetting>? safetyRatings = null, IGoogleAuthenticator? authenticator = null)

Parameters

modelName string

The name of the semantic retrieval model to use.

safetyRatings ICollection<SafetySetting>

A collection of safety settings to apply for content moderation. Optional.

authenticator IGoogleAuthenticator

An optional Google authenticator instance. If not provided, the platform's existing authenticator must be set.

Returns

SemanticRetrieverModel

A new instance of the SemanticRetrieverModel initialized with the specified parameters.

Exceptions

GenerativeAIException

Thrown when no authenticator is provided, and the platform's authenticator is not set.

CreateCorpusManager(IGoogleAuthenticator?)

Creates and initializes a new instance of the CorporaManager class to manage corpus operations using the currently configured platform and authentication mechanism.

public CorporaManager CreateCorpusManager(IGoogleAuthenticator? authenticator = null)

Parameters

authenticator IGoogleAuthenticator

An optional IGoogleAuthenticator instance used for authentication if the platform does not already have an authenticator configured.

Returns

CorporaManager

A fully initialized CorporaManager instance for managing corpora.

Exceptions

GenerativeAIException

Thrown when no authenticator is provided and the platform does not have an authenticator configured.

CreateFileSearchStoresClient()

Creates a client for File Search stores and their documents (managed retrieval-augmented generation).

public FileSearchStoresClient CreateFileSearchStoresClient()

Returns

FileSearchStoresClient

A FileSearchStoresClient that shares this instance's platform, HTTP client and logger.

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

Creates a new instance of the GeminiModel class, configured with the specified model name, generation settings, safety settings, system instructions, and optional HTTP client and logger for enhanced AI functionality. GeminiModel provides an interface to interact with specific generative AI models on the Google AI platform, offering tailored content generation capabilities.

public GeminiModel CreateGeminiModel(string modelName, GenerationConfig? config = null, ICollection<SafetySetting>? safetyRatings = null, string? systemInstruction = null)

Parameters

modelName string

The name of the Gemini model to be created. It identifies the specific type of AI model to interact with.

config GenerationConfig

Optional configuration details for generation, including parameters such as temperature, max tokens, and other settings.

safetyRatings ICollection<SafetySetting>

An optional collection of safety settings to restrict the model's output based on defined criteria.

systemInstruction string

Optional system-level instruction or guidelines provided to influence the model's behavior.

Returns

GeminiModel

A new instance of the GeminiModel class, configured with the provided inputs for generative AI tasks.

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

Instantiates a new generative model using the specified parameters. This method initializes and configures the generative model for AI-driven content generation, providing additional customization options through configuration and safety settings.

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

Parameters

modelName string

The name of the generative model to create.

config GenerationConfig

An optional configuration for generation settings, which may include parameters such as temperature, max tokens, or top-p values.

safetyRatings ICollection<SafetySetting>

An optional collection of safety settings that define acceptable content safety parameters and thresholds.

systemInstruction string

An optional system instruction to guide the generative model's initialization or behavior.

Returns

GenerativeModel

Returns an instance of a configured GenerativeModel.