mirror of
				https://github.com/hwchase17/langchain.git
				synced 2025-11-03 17:54:10 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			887 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			887 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
```python
 | 
						|
from langchain.chains import ConversationChain
 | 
						|
from langchain.memory import ConversationBufferMemory
 | 
						|
 | 
						|
conversation = ConversationChain(
 | 
						|
    llm=chat,
 | 
						|
    memory=ConversationBufferMemory()
 | 
						|
)
 | 
						|
 | 
						|
conversation.run("Answer briefly. What are the first 3 colors of a rainbow?")
 | 
						|
# -> The first three colors of a rainbow are red, orange, and yellow.
 | 
						|
conversation.run("And the next 4?")
 | 
						|
# -> The next four colors of a rainbow are green, blue, indigo, and violet.
 | 
						|
```
 | 
						|
 | 
						|
<CodeOutputBlock lang="python">
 | 
						|
 | 
						|
```
 | 
						|
    'The next four colors of a rainbow are green, blue, indigo, and violet.'
 | 
						|
```
 | 
						|
 | 
						|
</CodeOutputBlock>
 | 
						|
 | 
						|
Essentially, `BaseMemory` defines an interface of how `langchain` stores memory. It allows reading of stored data through `load_memory_variables` method and storing new data through `save_context` method. You can learn more about it in the [Memory](/docs/modules/memory/) section.
 | 
						|
 |