ChatHistory class

Constructors

ChatHistory({int keepRecentPairs = 2})
ChatHistory.fromJson(Map<String, dynamic> json)
factory

Properties

fullHistory List<Message>
final
hashCode int
The hash code for this object.
no setterinherited
images List<String>
Returns all image paths in the current history order
no setter
keepRecentPairs int
final
length int
no setter
messages List<Message>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addMessage({required Role role, required String content, List<String>? images}) → void
autoTrimForSpace(Llama llama, {int reserveTokens = 100}) bool
clear() → void
exportFormat(ChatFormat format, {bool leaveLastAssistantOpen = false}) String
--- STATELESS API (Classic) --- Exports the ENTIRE history. Use this when initializing context, or after calling llama.clear().
exportWithMedia(ChatFormat format, {bool leaveLastAssistantOpen = false}) → (String, List<LlamaInput>)
Exports both the formatted prompt and the corresponding LlamaInput list. This is a convenience method for use with llama.generateWithMedia.
getLatestTurn(ChatFormat format) String
--- STATEFUL API (New) --- Exports ONLY the latest turn (User + Optional Empty Assistant). Use this with llama.setPrompt() to append to existing context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldTrimBeforePrompt(Llama llama, String newPrompt) bool
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited