GenerativeModel Class

A Generative AI Model that extends BaseModel

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public class GenerativeModel : BaseModel, 
	IGenerativeModel
Inheritance
Object    ApiBase    BaseClient    BaseModel    GenerativeModel
Derived
Implements
IGenerativeModel

Constructors

GenerativeModel(String, ModelParams, HttpClient, ILogger) Represents a generative AI model designed to handle text generation tasks with configurable settings, platform adapters, safety measures, and advanced functionalities such as function calling and content caching.
GenerativeModel(IPlatformAdapter, String, GenerationConfig, ICollectionSafetySetting, String, HttpClient, ILogger) Represents a generative AI model, providing functionality for text generation tasks.
GenerativeModel(String, String, GenerationConfig, ICollectionSafetySetting, String, HttpClient, ILogger) Represents a generative AI model designed for text generation and related tasks.

Properties

CachedContent Gets or sets preloaded or previously generated content associated with the generative model. This property allows for the reuse of specific content, bypassing the need for regeneration, while ensuring alignment with the current model configuration and constraints.
CachingClient Gets or sets the client used for managing cached content operations in the generative AI model. This property provides an interface for interacting with caching-related functionalities, such as creating, updating, retrieving, or deleting cached content. It helps manage content efficiently by leveraging the CachingClient within the model's context.
Config Gets or sets the configuration for content generation. This property defines specific parameters, such as temperature and maximum output tokens, that influence the behavior and output of the generative model. It serves as a central customization point for tailoring the content creation process.
FunctionCallingBehaviour 
FunctionTools 
HttpClient
(Inherited from ApiBase)
Logger
(Inherited from ApiBase)
Model Gets or sets the name or identifier of the model used for generative tasks. This property determines the specific model implementation to be used for content generation and other related operations.
Platform
(Inherited from BaseClient)
SafetySettings Gets or sets the collection of safety settings that define constraints or limits on content generation. This property is used to enforce specified safety rules to ensure the generated content aligns with predetermined guidelines or restrictions.
SerializerOptions JSON serialization options used for API requests and responses.
(Inherited from ApiBase)
SystemInstruction Gets or sets the system instruction used to guide the behavior of the generative model. This property defines the overarching context or guideline for content generation, shaping the responses produced by the model to align with specific requirements or objectives.
ToolConfig 
UseCodeExecutionTool Indicates whether the code execution tool is enabled. The code execution tool facilitates the integration of code execution capabilities for processing specific requests and enhancing model functionalities.
UseGoogleSearch Specifies whether the Google Search integration is enabled. This feature allows utilizing the Google Search Tool within the generative model for enhanced search and retrieval capabilities.
UseGrounding Indicates whether grounding is enabled. Grounding integrates external tools, such as Google Search Retrieval, to support specific generative model requests for enhanced content generation.
UseJsonMode Determines whether JSON mode is enabled. JSON mode adjusts the content generation response to specifically produce outputs in JSON format as defined in generation configurations.

Methods

AddAuthorizationHeader
(Inherited from BaseClient)
AddFunctionTool 
BatchEmbedContentAsync Embeds a batch of content using the specified Generative AI model.
(Inherited from BaseModel)
CheckAndHandleErrors
(Inherited from ApiBase)
CheckBlockedResponse
(Inherited from BaseModel)
CountTokensAsync(CountTokensRequest) Counts tokens asynchronously based on the provided request.
CountTokensAsync(GenerateContentRequest) Counts the number of tokens in the content based on the provided GenerateContentRequest.
CountTokensAsync(IEnumerableContent) Asynchronously counts the tokens in the given contents.
CountTokensAsync(IEnumerablePart) Asynchronously counts the tokens in the provided collection of parts.
CountTokensAsync(String, CountTokensRequest) Counts the number of tokens in a given input using the provided model and request.
(Inherited from BaseModel)
DeleteAsync Sends a DELETE request to the specified URL.
(Inherited from ApiBase)
DeserializeT(HttpResponseMessage) Deserializes a JSON string into an object of the specified type.
(Inherited from ApiBase)
DeserializeT(String) Deserializes a JSON string into an object of the specified type.
(Inherited from ApiBase)
DisableFunctions Disable Global Functions
EmbedContentAsync Embeds content using the specified Generative AI Model.
(Inherited from BaseModel)
EnableFunctions Enable Global Functions
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GenerateAnswerAsync(GenerateAnswerRequest, CancellationToken) Generates an answer asynchronously based on the provided request.
GenerateAnswerAsync(String, GenerateAnswerRequest, CancellationToken) Generates a grounded answer from the model given an input GenerateAnswerRequest.
(Inherited from BaseModel)
GenerateAnswerAsync(String, AnswerStyle, ICollectionSafetySetting, CancellationToken) Generates an answer asynchronously based on the given prompt and specified parameters.
GenerateContentAsync(GenerateContentRequest, CancellationToken) Generates content asynchronously based on the given input parameters.
GenerateContentAsync(IEnumerablePart, CancellationToken) Generate content based on a sequence of Part objects.
GenerateContentAsync(String, GenerateContentRequest) Generates a model response given an input GenerateContentRequest.
(Inherited from BaseModel)
GenerateContentAsync(String, CancellationToken) Generates content asynchronously based on the specified text input prompt.
GenerateContentAsync(String, String, String, CancellationToken) Generates content asynchronously based on the provided text prompt and an inline file path.
GenerateContentAsyncT(GenerateContentRequest, CancellationToken) Generates content asynchronously using JSON mode based on the given input parameters and converts the resulting JSON into a C# object of type T.
GenerateContentStreamAsync Streams model responses chunk by chunk given an input GenerateContentRequest.
(Inherited from BaseModel)
GenerateObjectAsyncT(GenerateContentRequest, CancellationToken) Generates content asynchronously using JSON mode based on the given input parameters and converts the resulting JSON into a C# object of type T.
GenerateObjectAsyncT(IEnumerablePart, CancellationToken) Generates content asynchronously using JSON mode based on the specified content generation request parts and converts the resulting JSON into a C# object of type T.
GenerateObjectAsyncT(String, CancellationToken) Generates content asynchronously using JSON mode based on the specified text input prompt and converts the resulting JSON into a C# object of type T.
GetAsyncT Sends a GET request to the specified URL.
(Inherited from ApiBase)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
PrepareRequest 
SendAsyncTRequest, TResponse Sends an HTTP request (e.g., POST, PUT, or PATCH) to the specified URL.
(Inherited from ApiBase)
StartChat Start a Chat Session
StreamAsyncTRequest, TResponse Streams responses by sending an HTTP request with a JSON payload and yielding the deserialized items as they arrive.
(Inherited from ApiBase)
StreamContentAsync(GenerateContentRequest, CancellationToken) Streams content generation results asynchronously based on a given request and optional cancellation token.
StreamContentAsync(IEnumerableContent, CancellationToken) Streams generated content as an asynchronous enumerable based on the provided request.
StreamContentAsync(IEnumerablePart, CancellationToken) Streams content generation based on a GenerateContentRequest asynchronously.
StreamContentAsync(String, CancellationToken) Streams content generation based on a string message.
StreamContentAsync(String, String, String, CancellationToken) Streams content generation asynchronously based on the given input prompt, file URI, and MIME type.
ToStringReturns a string that represents the current object.
(Inherited from Object)
UploadFileWithProgressAsync(String, String, ActionDouble, DictionaryString, String, CancellationToken) Uploads a file to the specified URL with progress reporting.
(Inherited from ApiBase)
UploadFileWithProgressAsync(Stream, String, String, String, ActionDouble, DictionaryString, String, CancellationToken)
(Inherited from ApiBase)
ValidateGenerateContentRequest 

Fields

See Also