Project 7: Restaurant Menu Chatbot
AI Engineer
Builds on these lessons
Current Task
Objective
ConversationBufferMemory stores every past turn of a conversation so a chain can reference earlier messages when generating the next one.
Task: add two turns to a ConversationBufferMemory and print its buffer.
index.py
from langchain.memory import ConversationBufferMemory
memory = ConversationBufferMemory()
memory.save_context({"input": "What's on the menu?"}, {"output": "Pasta and salad."})
memory.save_context({"input": "Any vegan options?"}, {"output": "Yes, the salad is vegan."})
print(memory.buffer)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview