🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Project 8: Event Invitation Assistant

AI Engineer

Builds on these lessons

Current Task

Objective

Wiring ConversationBufferMemory into a real chain means every new call automatically includes the full prior conversation as context.

Task: attach memory to a ConversationChain and print how many messages it holds after two turns.

index.py
from langchain.memory import ConversationBufferMemory from langchain.chains import ConversationChain from langchain_openai import ChatOpenAI memory = ConversationBufferMemory() conversation = ConversationChain(llm=ChatOpenAI(model="gpt-4o-mini"), memory=memory) conversation.predict(input="Draft an invitation for a birthday party.") conversation.predict(input="Make it shorter.") print(len(memory.chat_memory.messages))

* Hint: Correct characters turn green, incorrect ones turn red.

Live Preview
🖼️

Verify your code to see the preview