Langchain - Memory

Hi all,

If you are looking into implementing the langchain memory to mimic a chatbot in streamlit using openAI API, here is the code snippet that might help you.

you need to put st.cache_resource and put all the functions in a function call.

6 Likes

To anyone in the same boat, the decorator below also works:

@st.cache(allow_output_mutation=True)

1 Like

By adding memory to cache, it saves same history for all session.
How to save langchain’s chat history per session?