https://github.com/ray-project/llm-numbers https://github.com/mshumer/gpt-prompt-engineer https://js.langchain.com/docs/modules/data_connection/retrievers/how_to/self_query/
from langchain.schema import messages_from_dict, messages_to_dict extracted_messages = original_chain.memory.chat_memory.messages
[HumanMessage(content='what do you know about Python in less than 10 words', additional_kwargs={}), AIMessage(content='Python is a high-level programming language.', additional_kwargs={})]
ingest_to_db = messages_to_dict(extracted_messages)
[{'type': 'human', 'data': {'content': 'what do you know about Python in less than 10 words', 'additional_kwargs': {}}}, {'type': 'ai', 'data': {'content': 'Python is a high-level programming language.', 'additional_kwargs': {}}}]
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')