Method Clone
- Namespace
- LMKit.TextGeneration.Chat
- Assembly
- LM-Kit.NET.dll
Clone()
Creates a deep copy of the current ChatHistory instance.
public ChatHistory Clone()
Returns
- ChatHistory
A new ChatHistory object that is a deep copy of the current instance.
Examples
Branch a conversation:
history.AddMessage(AuthorRole.User, "Tell me about cats.");
history.AddMessage(AuthorRole.Assistant, "Cats are domestic animals...");
// Create a branch to explore a different direction
ChatHistory branch = history.Clone();
branch.AddMessage(AuthorRole.User, "Now tell me about dogs instead.");
Remarks
This method serializes the current instance and then deserializes it to create a deep copy, ensuring that all nested objects and references are also copied.