I’m developing a new page for my app that will use LangChain to interact with my Database via OpenAI - it’s working great for the most part!
However, during some submissions of the st.chat_input field and the st.chat_message, the page is acting funny… as soon as I hit submit the message I just typed will overwrite the last message that was in the thread, and you don’t see a RUNNING indicator for streamlit. If you wait a little bit and reload the page (by clicking the navigation, not refreshing) the question and answer will render property. It almost seems that as the chat starts to get towards the bottom of the page and the input control it acts funny…
Anyone have any thoughts on where to look or what might be wrong?
Here’s how you can manage a chat application in Streamlit using session state:
import streamlit as st
if 'chat_history' not in st.session_state:
st.session_state.chat_history = []
for message in st.session_state.chat_history:
st.chat_message(message['role'], message['content'])
user_input = st.chat_input("Say something...")
if user_input:
st.session_state.chat_history.append({'role': 'user', 'content': user_input})
response = "This is a response to your message."
st.session_state.chat_history.append({'role': 'bot', 'content': response})
Kind Regards,
Sahir Maharaj
Data Scientist | AI Engineer
Thank you @sahirmaharaj ! This results in the same behaviour - looks like this is a common bug from the streamlit-authentication. The author is working on it.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
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.
Performance cookies
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.
Functional cookies
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.
Targeting cookies
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.