File size: 393 Bytes
36c0029
de4ad29
 
 
36c0029
 
de4ad29
1
2
3
4
5
6
7
from langchain.memory import ConversationBufferWindowMemory
from langchain.memory.chat_message_histories import StreamlitChatMessageHistory

msgs = StreamlitChatMessageHistory(key="langchain_messages")

memory3 = ConversationBufferWindowMemory(
    k=2, memory_key='chat_history', return_messages=True, output_key='answer', human_prefix="<|user|>", ai_prefix="<|assistant|>", chat_memory=msgs)