ConversationSession Class

Represents a conversation session with memory.

Inheritance

Object

ConversationSession

Namespace: Radzen

Assembly: Radzen.Blazor.dll

Syntax

public class ConversationSession

Constructors

ConversationSessionlink

Represents a conversation session with memory.

Declaration
public ConversationSession()

Properties

CreatedAtlink

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.

Idlink

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

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

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

Gets or sets the list of messages in the conversation.

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

Methods

AddMessagelink

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.

Clearlink

Clears all messages from the conversation.

Declaration
public void Clear()

GetFormattedMessageslink

Gets the conversation messages formatted for the AI API.

Declaration
public List<object> GetFormattedMessages(string systemPrompt)
Parameters
Type Name Description
string systemPrompt The system prompt to include.
Returns
Type Description
List<object>A list of message objects for the AI API.
An error has occurred. This app may no longer respond until reloaded. Reload 🗙