diff --git a/stapp.py b/stapp.py index 99c79e0..a59a8ce 100644 --- a/stapp.py +++ b/stapp.py @@ -82,6 +82,11 @@ if "messages" not in st.session_state: st.session_state.messages = [] for msg in st.session_state.messages: with st.chat_message(msg["role"]): st.markdown(msg["content"], unsafe_allow_html=True) +# IME composition fix (macOS only) - prevents Enter from submitting during CJK input +if os.name != 'nt': + import streamlit.components.v1 as components + components.html('', height=0) + if prompt := st.chat_input("请输入指令"): st.session_state.messages.append({"role": "user", "content": prompt}) with st.chat_message("user"): st.markdown(prompt, unsafe_allow_html=False) # 小心 XSS