Chat message history stores a history of the message interactions in a chat.
Message from an AI.
An AIMessage is returned from a chat model as a response to a prompt.
This message represents the output of the model and consists of both the raw output as returned by the model and standardized fields (e.g., tool calls, usage metadata) added by the LangChain framework.
Base abstract message class.
Messages are the inputs and outputs of a chat model.
Examples include HumanMessage,
AIMessage, and
SystemMessage.
Message from the user.
A HumanMessage is a message that is passed in from a user to the model.
Abstract base class for storing chat message history.
Implementations guidelines:
Implementations are expected to over-ride all or some of the following methods:
add_messages: sync variant for bulk addition of messagesaadd_messages: async variant for bulk addition of messagesmessages: sync variant for getting messagesaget_messages: async variant for getting messagesclear: sync variant for clearing messagesaclear: async variant for clearing messagesadd_messages contains a default implementation that calls add_message
for each message in the sequence. This is provided for backwards compatibility
with existing implementations which only had add_message.
Async variants all have default implementations that call the sync variants. Implementers can choose to override the async implementations to provide truly async implementations.
Usage guidelines:
When used for updating history, users should favor usage of add_messages
over add_message or other variants like add_user_message and add_ai_message
to avoid unnecessary round-trips to the underlying persistence layer.
In memory implementation of chat message history.
Stores messages in a memory list.