Content Class

The base structured datatype containing multi-part content of a message. A Content includes a Role field designating the producer of the Content and a Parts field containing multi-part data that contains the content of the message turn.

Definition

Namespace: GenerativeAI.Types
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public sealed class Content
Inheritance
Object    Content

Constructors

ContentInitializes a new instance of the Content class
Content(IEnumerablePart, String)Initializes a new instance of the Content class

Properties

Parts Ordered Parts that constitute a single message. Parts may have different MIME types.
Role Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
ToStringReturns a string that represents the current object.
(Inherited from Object)

Extension Methods

AddInlineData Adds inline data (for images, audio, etc.) as a new Part to this Content.
(Defined by ContentExtensions)
AddInlineFile
(Defined by ContentExtensions)
AddPart Adds a single Part to this Content.
(Defined by ContentExtensions)
AddParts Adds multiple Part objects to this Content.
(Defined by ContentExtensions)
AddRemoteFile Adds a remote file to the GenerateContentRequest using its URL and MIME type.
(Defined by ContentExtensions)
AddRemoteFile Adds a remote file reference as a new Part to this Content.
(Defined by ContentExtensions)
AddText Adds a single text Part to this Content.
(Defined by ContentExtensions)
ExtractCodeBlocks Extracts all CodeBlock from the text Parts of Content object.
(Defined by ContentExtensions)
ExtractJsonBlocks Extracts all JSON string from the text Parts of Content object.
(Defined by ContentExtensions)
ToObjectT Converts the JSON content of a Content object into an instance of the specified type.
(Defined by ContentExtensions)

See Also