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.
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.
To anyone in the same boat, the decorator below also works:
@st.cache(allow_output_mutation=True)
By adding memory to cache, it saves same history for all session.
How to save langchain’s chat history per session?
This is an old thread, but adding an important addition - I was running into major problems with memory leaks and going over the 1GB community cloud limit every couple days. It turns out it wasn’t LangChain but LangSmith. Turning off LangSmith brought the problem under control. It was easy to overlook because setting up LangSmith just requires some environment variables. I love LangSmith and am sad to lose the insights. I have no idea what’s going on under the hood.
Hopefully this helps somebody else out there.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.