ChatMessageHistory class final

A simple in-memory implementation of a chat message history. Stores messages in an in memory list.

Inheritance

Constructors

ChatMessageHistory.new({List<ChatMessage>? messages})
A simple in-memory implementation of a chat message history. Stores messages in an in memory list.
ChatMessageHistory.fromMap(Map<String, dynamic> map)
Convert the history from a map.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addAIChatMessage(String message) Future<void>
Add an AI message to the history.
inherited
addChatMessage(ChatMessage message) Future<void>
Add ChatMessage to the history.
override
addHumanChatMessage(String message) Future<void>
Add a human message to the history.
inherited
addToolChatMessage({required String toolCallId, required String content}) Future<void>
Add a Tool response message to the history.
inherited
clear() Future<void>
Clear the history.
override
getChatMessages() Future<List<ChatMessage>>
Return a list of messages.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeFirst() Future<ChatMessage>
Removes and returns the first (oldest) element of the history.
override
removeLast() Future<ChatMessage>
Removes and returns the last (newest) element of the history.
override
toMap() Map<String, dynamic>
Convert the history to a map.
toString() String
A string representation of this object.
inherited

Operators

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