Every time I chat why the previous response is unformatted, not treated as Markdown
if user_input:
# first add the message to message_history
st.session_state["message_history"].append({"role": "user", "content": user_input})
with st.chat_message("user"):
st.text(user_input)
# first add the message to message_history
with st.chat_message("assistant"):
ai_message = st.write_stream(
message_chunk.content
for message_chunk, metadata in chatbot.stream(
{"messages": [HumanMessage(content=user_input)]},
config={"configurable": {"thread_id": "thread-1"}},
stream_mode="messages",
)
)
st.session_state["message_history"].append({"role": "assistant", "content": ai_message})
