I’m testing out Streamlit’s chatbot interface. I wanted to incorporate the Streamlit spinner. This is the code block that gets a pre-generated chart from a getChart function. The charts are randomly selected in the function.
# Accept user input
if prompt := st.chat_input("Enter your question here"):
# Add user message to chat history
st.session_state.messages[dataset.id].append({"role": "user", "content": prompt})
# Display user message in chat message container
with st.chat_message("user"):
st.markdown(prompt)
# Display assistant response in chat message container
with st.chat_message("assistant"), st.spinner("Answering your question..."):
data = getChart()
st.write(data)
# Add assistant response to chat history
st.session_state.messages[dataset.id].append({"role": "assistant", "content": data})
When I enter in a second prompt, I get a weird effect when the second image is loading in. It looks like this:
The after image disappears after the new chart is selected.
Any ideas why this is happening?
Thanks!