ChatMessage Class

Represents a chat message in the RadzenAIChat component.

Inheritance

Object

ChatMessage

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class ChatMessage

Constructors

ChatMessageLink to this section

Represents a chat message in the RadzenAIChat component.

Declaration
public ChatMessage()

Properties

AdditionalPropertiesLink to this section

Gets or sets additional data about the message, for example the files an answer changed or the credits it used. Streaming responses collect the AdditionalProperties of their updates here; render them with MessageFooterTemplate or UsageTemplate.

Declaration
public Microsoft.Extensions.AI.AdditionalPropertiesDictionary AdditionalProperties { get; set; }
Property Value
Type Description
Microsoft.Extensions.AI.AdditionalPropertiesDictionaryGets or sets additional data about the message, for example the files an answer changed or the credits it used. Streaming responses collect the AdditionalProperties of their updates here; render them with MessageFooterTemplate or UsageTemplate.

AttachmentsLink to this section

Gets or sets the files attached to the message.

Declaration
public List<ChatAttachment> Attachments { get; set; }
Property Value
Type Description
List<ChatAttachment>Gets or sets the files attached to the message.

CitationsLink to this section

Gets or sets the sources the answer is based on: citations the provider attached to the response and citations returned by tools.

Declaration
public List<ChatCitation> Citations { get; set; }
Property Value
Type Description
List<ChatCitation>Gets or sets the sources the answer is based on: citations the provider attached to the response and citations returned by tools.

ContentLink to this section

Gets or sets the content of the message.

Declaration
public string Content { get; set; }
Property Value
Type Description
stringGets or sets the content of the message.

IdLink to this section

Gets or sets the unique identifier for the message.

Declaration
public string Id { get; set; }
Property Value
Type Description
stringGets or sets the unique identifier for the message.

IsStreamingLink to this section

Gets or sets whether this message is currently streaming.

Declaration
public bool IsStreaming { get; set; }
Property Value
Type Description
boolGets or sets whether this message is currently streaming.

IsUserLink to this section

Gets or sets whether this message is from the user.

Declaration
public bool IsUser { get; set; }
Property Value
Type Description
boolGets or sets whether this message is from the user.

KindLink to this section

Gets or sets the kind of the message. Default is Message; the other kinds are entries the application adds with ChatMessage).

Declaration
public ChatMessageKind Kind { get; set; }
Property Value
Type Description
ChatMessageKindGets or sets the kind of the message. Default is Message; the other kinds are entries the application adds with ChatMessage).

ReasoningLink to this section

Gets or sets the reasoning the model produced before answering, when the model exposes it.

Declaration
public string Reasoning { get; set; }
Property Value
Type Description
stringGets or sets the reasoning the model produced before answering, when the model exposes it.

RoleLink to this section

Gets or sets the role associated with the message (e.g., "user", "assistant").

Declaration
public string Role { get; set; }
Property Value
Type Description
stringGets or sets the role associated with the message (e.g., "user", "assistant").

TimestampLink to this section

Gets or sets the timestamp when the message was created.

Declaration
public DateTime Timestamp { get; set; }
Property Value
Type Description
DateTimeGets or sets the timestamp when the message was created.

ToolCallsLink to this section

Gets or sets the tool calls the assistant made while producing this message.

Declaration
public List<ChatToolCall> ToolCalls { get; set; }
Property Value
Type Description
List<ChatToolCall>Gets or sets the tool calls the assistant made while producing this message.

UsageLink to this section

Gets or sets the token usage reported by the model for this response, when the provider reports it.

Declaration
public Microsoft.Extensions.AI.UsageDetails Usage { get; set; }
Property Value
Type Description
Microsoft.Extensions.AI.UsageDetailsGets or sets the token usage reported by the model for this response, when the provider reports it.

UserIdLink to this section

Gets or sets the ID of the user who sent the message.

Declaration
public string UserId { get; set; }
Property Value
Type Description
stringGets or sets the ID of the user who sent the message.

Methods

GetPartsLink to this section

Splits the message into its parts in the order the assistant produced them: the text written before a tool call, the call, the text written after it. Tool calls are placed by TextPosition; calls with the same position keep their order in ToolCalls. Empty text is skipped. Each text part is rendered as Markdown on its own, so a call that falls inside a list or a code block splits that block in two.

Declaration
public IReadOnlyList<ChatMessagePart> GetParts()
Returns
Type Description
IReadOnlyList<ChatMessagePart>The parts of the message.

MergeAdditionalPropertiesLink to this section

Merges additional data into AdditionalProperties.

Declaration
public void MergeAdditionalProperties(Microsoft.Extensions.AI.AdditionalPropertiesDictionary properties)
Parameters
Type Name Description
Microsoft.Extensions.AI.AdditionalPropertiesDictionary properties The data to merge. Nothing happens when it is null or empty.
An error has occurred. This app may no longer respond until reloaded. Reload 🗙