Repeated assistant answer when spinning

Hi there,

The previous assistant message was repeated when the new answer was being generated. The same issue can be found in this app: https://llama2.streamlit.app/

# Generate a new response if last message is not from assistant
if st.session_state.messages[-1]["role"] != "assistant":
    with st.chat_message("assistant"):
        with st.spinner("Thinking..."):
            response = generate_llama2_response(prompt)
            placeholder = st.empty()
            full_response = ''
            for item in response:
                full_response += item
                placeholder.markdown(full_response)
            placeholder.markdown(full_response)
    message = {"role": "assistant", "content": full_response}
    st.session_state.messages.append(message)

The previous assistant’s answer won’t be repeated if the st.spinner is removed. Is there another way to solve this? thank you

2 Likes

Same problem here, and I had to downgrade the streamlit version to resolve it. Any other solutions?

I am having the same problem as of streamlit version 1.33. On earlier versions it works fine