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

1 Like

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