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
authorRoleAuthorRoleSpecifies the author's role.
contentstringSpecifies 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
AddMessage(Message)
Adds a message to the history.
public void AddMessage(ChatHistory.Message message)
Parameters
messageChatHistory.MessageA Message object that specifies the message to be added.