Optional
fields: BufferMemoryInputOptional
inputOptional
outputLoads the memory variables. It takes an InputValues
object as a
parameter and returns a Promise
that resolves with a
MemoryVariables
object.
InputValues
object.
A Promise
that resolves with a MemoryVariables
object.
Method to add user and AI messages to the chat history in sequence.
The input values from the user.
The output values from the AI.
Promise that resolves when the context has been saved.
Generated using TypeDoc
The
BufferMemory
class is a type of memory component used for storing and managing previous chat messages. It is a wrapper aroundChatMessageHistory
that extracts the messages into an input variable. This class is particularly useful in applications like chatbots where it is essential to remember previous interactions. Note: The memory instance represents the history of a single conversation. Therefore, it is not recommended to share the same history or memory instance between two different chains. If you deploy your LangChain app on a serverless environment, do not store memory instances in a variable, as your hosting provider may reset it by the next time the function is called.