Skip to content

ChatHistory

Namespace: LLama.Common

The chat history class

public class ChatHistory

Inheritance ObjectChatHistory

Properties

Messages

List of messages in the chat

public List<Message> Messages { get; set; }

Property Value

List<Message>

Constructors

ChatHistory()

Create a new instance of the chat content class

public ChatHistory()

ChatHistory(Message[])

Create a new instance of the chat history from array of messages

public ChatHistory(Message[] messageHistory)

Parameters

messageHistory Message[]

Methods

AddMessage(AuthorRole, String)

Add a message to the chat history

public void AddMessage(AuthorRole authorRole, string content)

Parameters

authorRole AuthorRole
Role of the message author

content String
Message content

ToJson()

Serialize the chat history to JSON

public string ToJson()

Returns

String

FromJson(String)

Deserialize a chat history from JSON

public static ChatHistory FromJson(string json)

Parameters

json String

Returns

ChatHistory