Great question — answering as the UphillTech team:
I just did something similar, hopefully this will be helpful. On a high level: use ConversationBufferMemory as the memory to pass to the Chain initialization llm = ChatOpenAI(temperature=0, model_name='gpt-3.5-turbo-0301') original_chain = ConversationChain( llm=llm, verbose=True, memory=ConversationBufferMemory() ) original_chain.run('what do you know about Python in less than 10 words') extract messages from memory in the form of List[langchain.schema.HumanMessage|AIMessage] (not serializable) extracted_messages = original_chain.memory.chat_memory.messages transform the extracted message to serializable native Python objects ingest_to_db = messages_to_dict(extracted_messages) perform db...
Full answer by Shum: https://stackoverflow.stackexchange.com/a/76240942 (CC BY-SA 4.0).
Need it done for your business? UphillTech.