ConversationSession Class

Represents a conversation session with memory.

Inheritance

Object

ConversationSession

Namespace: Radzen

Assembly: Radzen.Blazor.dll

Syntax

public class ConversationSession

Constructors

ConversationSessionLink to this section

Represents a conversation session with memory.

Declaration
public ConversationSession()

Properties

CreatedAtLink to this section

Gets or sets the timestamp when the conversation was created.

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

HistoryLink to this section

Gets or sets the conversation history sent to the model, including tool calls and tool results.

Declaration
public List<Microsoft.Extensions.AI.ChatMessage> History { get; set; }
Property Value
Type Description
List<Microsoft.Extensions.AI.ChatMessage>Gets or sets the conversation history sent to the model, including tool calls and tool results.

IdLink to this section

Gets or sets the unique identifier for the conversation session.

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

LastUpdatedLink to this section

Gets or sets the timestamp when the conversation was last updated.

Declaration
public DateTime LastUpdated { get; set; }
Property Value
Type Description
DateTimeGets or sets the timestamp when the conversation was last updated.

MaxMessagesLink to this section

Gets or sets the maximum number of messages to keep in memory.

Declaration
public int MaxMessages { get; set; }
Property Value
Type Description
intGets or sets the maximum number of messages to keep in memory.

MessagesLink to this section

Gets or sets the list of messages in the conversation as displayed by RadzenAIChat.

Declaration
public List<ChatMessage> Messages { get; set; }
Property Value
Type Description
List<ChatMessage>Gets or sets the list of messages in the conversation as displayed by RadzenAIChat.

TitleLink to this section

Gets or sets the title of the conversation. Defaults to the beginning of the first user message.

Declaration
public string Title { get; set; }
Property Value
Type Description
stringGets or sets the title of the conversation. Defaults to the beginning of the first user message.

UserIdLink to this section

Gets or sets the user the conversation belongs to. Set through UserId or CancellationToken); CancellationToken) filters by it.

Declaration
public string UserId { get; set; }
Property Value
Type Description
stringGets or sets the user the conversation belongs to. Set through UserId or CancellationToken); CancellationToken) filters by it.

Methods

AddHistoryLink to this section

Adds messages to the history sent to the model and manages memory limits. Tool calls and their results are kept together.

Declaration
public void AddHistory(IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages)
Parameters
Type Name Description
IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages The messages.

AddMessageLink to this section

Adds a message to the conversation and manages memory limits.

Declaration
public void AddMessage(string role, string content)
Parameters
Type Name Description
string role The role of the message sender.
string content The message content.

AddMessageLink to this section

Adds a message to the conversation and manages memory limits.

Declaration
public void AddMessage(ChatMessage message)
Parameters
Type Name Description
ChatMessage message

ClearLink to this section

Clears all messages from the conversation.

Declaration
public void Clear()
An error has occurred. This app may no longer respond until reloaded. Reload 🗙