Here we'll cover the basics of interacting with an arbitrary memory class.Let's take a look at how to use ConversationBufferMemory in chains.
ConversationBufferMemory is an extremely simple form of memory that just keeps a list of chat messages in a buffer
and passes those into the prompt template.from langchain.memory import ConversationBufferMemorymemory = ConversationBufferMemory()memory.chat_memory.add_user_message("hi!")memory.chat_memory.add_ai_message("what's up?")When using memory in a chain, there are a few key concepts to understand.
Note that here we cover general concepts that are useful for most types of memory.
Each individual memory type may very well have its own parameters and concepts that are necessary to understand.What variables get returned from memory‚ÄãBefore going into the chain, various variables are read from memory.
These have specific names which need to align with the variables the chain expects.
You can see what these variables are by calling memory.load_memory_variables({}).
Note that the empty dictionary that we pass in is just a placeholder for real variables.
If the memory type you are using is dependent upon the input variables, you may need to pass some in.memory.load_memory_variables({})    {'history': "Human: hi!\nAI: what's up?"}In this case, you can see that load_memory_variables returns a single key, history.
This means that your chain (and likely your prompt) should expect an input named history.
You can usually control this variable through parameters on the memory class.
Most LLM applications have a conversational interface. An essential component of a conversation is being able to refer to information introduced earlier in the conversation.
Most LLM applications have a conversational interface. An essential component of a conversation is being able to refer to information introduced earlier in the conversation. ->: Here we'll cover the basics of interacting with an arbitrary memory class.Let's take a look at how to use ConversationBufferMemory in chains.
ConversationBufferMemory is an extremely simple form of memory that just keeps a list of chat messages in a buffer
and passes those into the prompt template.from langchain.memory import ConversationBufferMemorymemory = ConversationBufferMemory()memory.chat_memory.add_user_message("hi!")memory.chat_memory.add_ai_message("what's up?")When using memory in a chain, there are a few key concepts to understand.
Note that here we cover general concepts that are useful for most types of memory.
Each individual memory type may very well have its own parameters and concepts that are necessary to understand.What variables get returned from memory‚ÄãBefore going into the chain, various variables are read from memory.
These have specific names which need to align with the variables the chain expects.
You can see what these variables are by calling memory.load_memory_variables({}).
Note that the empty dictionary that we pass in is just a placeholder for real variables.
If the memory type you are using is dependent upon the input variables, you may need to pass some in.memory.load_memory_variables({})    {'history': "Human: hi!\nAI: what's up?"}In this case, you can see that load_memory_variables returns a single key, history.
This means that your chain (and likely your prompt) should expect an input named history.
You can usually control this variable through parameters on the memory class.