Project 23: Weather Assistant Bot
AI Engineer
Current Task
Objective
Review day: apply windowed memory from day 9 to a running weather-query conversation.
Task: create a windowed memory with k=1, add two turns, and print the remaining message count.
index.py
from langchain.memory import ConversationBufferWindowMemory
memory = ConversationBufferWindowMemory(k=1)
memory.save_context({"input": "What's the weather in Tokyo?"}, {"output": "22C and sunny."})
memory.save_context({"input": "And tomorrow?"}, {"output": "19C with light rain."})
print(len(memory.chat_memory.messages))
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview