Table of Contents

Method AddMessage

Namespace
LMKit.TextGeneration.Chat
Assembly
LM-Kit.NET.dll

AddMessage(AuthorRole, string)

Adds a message to the history.

public void AddMessage(AuthorRole authorRole, string content)

Parameters

authorRole AuthorRole

Specifies the author's role.

content string

Specifies the message content.

Examples

using LMKit.Model;
using LMKit.TextGeneration.Chat;

LM model = LM.LoadFromModelID("llama-3.2-1b");
ChatHistory history = new ChatHistory(model);

// Add a system message (must be first if used)
history.AddMessage(AuthorRole.System, "You are a helpful coding assistant.");

// Add user and assistant messages
history.AddMessage(AuthorRole.User, "How do I create a list in Python?");
history.AddMessage(AuthorRole.Assistant, "You can create a list using: my_list = [1, 2, 3]");

Exceptions

ArgumentException

AddMessage(Message)

Adds a message to the history.

public void AddMessage(ChatHistory.Message message)

Parameters

message ChatHistory.Message

A Message object that specifies the message to be added.

Exceptions

ArgumentException