Class ChatSession
Represents a single chat session, including its metadata, settings, messages, and serialization logic.
Provides support for saving, loading, summarizing, and auto-saving the session.
Inheritance
object
ChatSession
Assembly: .dll
Syntax
public class ChatSession : IData
Constructors
ChatSession()
Declaration
Properties
AutoSave
Whether the session should automatically save on update.
Declaration
public bool AutoSave { get; set; }
Property Value
CreatedAt
Declaration
public UnixTime CreatedAt { get; }
Property Value
Type |
Description |
UnixTime |
|
Id
Unique identifier of the chat session.
Declaration
public string Id { get; }
Property Value
Last
The last message received from the assistant.
Declaration
public ChatCompletion Last { get; }
Property Value
LastException
Declaration
public Exception LastException { get; }
Property Value
Type |
Description |
Exception |
|
LastSummaryUpdate
Time when the summary was last updated.
Declaration
public UnixTime LastSummaryUpdate { get; }
Property Value
Type |
Description |
UnixTime |
|
MaxContextMessages
Maximum number of context messages to use before summarizing.
Declaration
public int MaxContextMessages { get; set; }
Property Value
Messages
List of all chat messages in the session.
Declaration
public List<ChatMessage> Messages { get; set; }
Property Value
Model
The AI model used for the chat.
Declaration
public Model Model { get; set; }
Property Value
ModelOptions
Optional parameters for model behavior.
Declaration
public ModelSettings ModelOptions { get; set; }
Property Value
ModerationOptions
Declaration
public ModerationOptions ModerationOptions { get; set; }
Property Value
Name
Name of the chat session.
Declaration
public string Name { get; set; }
Property Value
ReasoningOptions
Additional reasoning configuration.
Declaration
public ReasoningOptions ReasoningOptions { get; set; }
Property Value
RecentMessages
List of recent chat messages used for summarization.
Declaration
public List<ChatMessage> RecentMessages { get; }
Property Value
SpeechOutputOptions
Settings for speech output.
Declaration
public SpeechOutputOptions SpeechOutputOptions { get; set; }
Property Value
StartingMessage
The message shown to the user at the start of the session.
Declaration
public string StartingMessage { get; set; }
Property Value
Stream
Whether streaming responses are enabled.
Declaration
public bool Stream { get; set; }
Property Value
Summary
The current summary of the session.
Declaration
public string Summary { get; }
Property Value
SummaryModel
Model used to generate conversation summaries.
Declaration
public Model SummaryModel { get; set; }
Property Value
SystemInstruction
System instruction for the assistant.
Declaration
public string SystemInstruction { get; set; }
Property Value
UpdatedAt
Declaration
public UnixTime UpdatedAt { get; }
Property Value
Type |
Description |
UnixTime |
|
WebSearchOptions
Settings for web search integration.
Declaration
public WebSearchOptions WebSearchOptions { get; set; }
Property Value
Methods
ClearMessages()
Declaration
public void ClearMessages()
CreateFile(string, string, string)
Declaration
public static ChatSession CreateFile(string id = null, string name = null, string startingMessage = null)
Parameters
Type |
Name |
Description |
string |
id |
|
string |
name |
|
string |
startingMessage |
|
Returns
DeleteFile()
Declaration
Returns
DeleteFile(string)
Declaration
public static bool DeleteFile(string id)
Parameters
Type |
Name |
Description |
string |
id |
|
Returns
Equals(ChatSession)
Declaration
public bool Equals(ChatSession other)
Parameters
Returns
GENChat(ChatMessage)
Creates a text generation task using this chat session and message as the prompt.
Example:
chatSession.GENChat(chatMessage).SetModel(OpenAIModel.GPT4o).ExecuteAsync();
Declaration
public GENChatTask GENChat(ChatMessage chatMessage)
Parameters
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
LoadFile(string)
Declaration
public static ChatSession LoadFile(string id)
Parameters
Type |
Name |
Description |
string |
id |
|
Returns
Rewind()
Declaration
public (ChatMessage lastSent, ChatMessage lastReceived) Rewind()
Returns
SaveFile(string)
Declaration
public void SaveFile(string customPath = null)
Parameters
Type |
Name |
Description |
string |
customPath |
|
SaveFileAsync(string)
Declaration
public UniTask SaveFileAsync(string customPath = null)
Parameters
Type |
Name |
Description |
string |
customPath |
|
Returns
ToString()
Declaration
public override string ToString()
Returns