Markdown rendering of super long swallowing words

Why Does Markdown Swallow Words When Rendering Long Characters

Does it?

yes,When I use st. empty(). markdown(), I loop through 1000 words and when it exceeds a certain length, the page will shake when refreshing, and there is only one line left after rendering.

What are you passing to st.empty().markdown()?

if prompt := st.chat_input(“Shift + Enter 换行, Enter 发送”):
with st.chat_message(“user”, avatar=‘:adult:<200d>:computer:’):
st.markdown(prompt)
messages.append({“role”: “user”, “content”: prompt})
print(f"[user] {prompt}", flush=True)
with st.chat_message(“assistant”, avatar=‘:robot:’):
placeholder = st.empty()
for response in model.chat(tokenizer, messages, stream=True):
#print(response)
placeholder.markdown(response)
if torch.backends.mps.is_available():
torch.mps.empty_cache()
messages.append({“role”: “assistant”, “content”: response})
print(json.dumps(messages, ensure_ascii=False), flush=True)
st.button(“清空对话”, on_click=clear_chat_history)

This is my code

I see, the answer is in the docs:

st.empty

Insert a single-element container.

Inserts a container into your app that can be used to hold a single element.

So each time you insert a new element it replaces the former element.