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