from langchain.schema import messages_from_dict, messages_to_dict extracted_messages = original_chain.memory.chat_memory.messages
ingest_to_db = messages_to_dict(extracted_messages)
retrieve_from_db = json.loads(json.dumps(ingest_to_db))
retrieved_messages = messages_from_dict(retrieve_from_db)
retrieved_chat_history = ChatMessageHistory(messages=retrieved_messages)
retrieved_memory = ConversationBufferMemory(chat_memory=retrieved_chat_history)
reloaded_chain = ConversationChain( llm=llm, verbose=True, memory=retrieved_memory ) reloaded_chain.run('what about Javascript and Ruby')