Spaces:
Sleeping
Sleeping
File size: 512 Bytes
411a994 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from langchain.memory import ChatMessageHistory, ConversationBufferMemory
def get_memory():
"""
Create a conversation memory with the latest LangChain syntax.
"""
# Create a message history object
message_history = ChatMessageHistory()
# Create a memory that uses the message history
memory = ConversationBufferMemory(
memory_key="chat_history",
chat_memory=message_history,
return_messages=True,
output_key="output"
)
return memory
|