ChatMessage Constructors

Definition

Overloads

ChatMessage()

Initializes a new instance of the ChatMessage class.

ChatMessage(ChatRole, IList<AIContent>)

Initializes a new instance of the ChatMessage class.

ChatMessage(ChatRole, String)

Initializes a new instance of the ChatMessage class.

ChatMessage()

Source:
ChatMessage.cs

Initializes a new instance of the ChatMessage class.

C#
[System.Text.Json.Serialization.JsonConstructor]
public ChatMessage();
Attributes

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

ChatMessage(ChatRole, IList<AIContent>)

Source:
ChatMessage.cs

Initializes a new instance of the ChatMessage class.

C#
public ChatMessage(Microsoft.Extensions.AI.ChatRole role, System.Collections.Generic.IList<Microsoft.Extensions.AI.AIContent> contents);

Parameters

role
ChatRole

The role of the author of the message.

contents
IList<AIContent>

The contents for this message.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

ChatMessage(ChatRole, String)

Source:
ChatMessage.cs

Initializes a new instance of the ChatMessage class.

C#
public ChatMessage(Microsoft.Extensions.AI.ChatRole role, string? content);

Parameters

role
ChatRole

The role of the author of the message.

content
String

The contents of the message.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)