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