Spaces:
Running
Running
Commit
·
54d4413
1
Parent(s):
40ba016
优化提问时的消息展示顺序
Browse files
app.py
CHANGED
@@ -330,18 +330,20 @@ def app():
|
|
330 |
with st.chat_message("assistant"):
|
331 |
st.write("Hello👋, how can I help you today? 😄")
|
332 |
|
333 |
-
# Display chat messages from history on app rerun
|
334 |
for message in st.session_state.messages:
|
335 |
with st.chat_message(message["role"]):
|
336 |
st.markdown(message["content"][0])
|
|
|
|
|
|
|
|
|
337 |
|
338 |
#这里的session.state就是保存了这个对话会话的一些基本信息和设置
|
339 |
retrieved_chunks_for_user = searchVDB(user_question, st.session_state.embeddings_df, st.session_state.faiss_index)
|
340 |
-
#retrieved_chunks_for_user = []
|
341 |
prompt = decorate_user_question(user_question, retrieved_chunks_for_user)
|
342 |
st.session_state.messages.append({"role": "user", "content": [user_question, prompt]})
|
343 |
-
|
344 |
-
st.markdown(user_question)
|
345 |
# Display assistant response in chat message container
|
346 |
with st.chat_message("assistant"):
|
347 |
message_placeholder = st.empty()
|
|
|
330 |
with st.chat_message("assistant"):
|
331 |
st.write("Hello👋, how can I help you today? 😄")
|
332 |
|
333 |
+
# Display chat messages from history on app rerun
|
334 |
for message in st.session_state.messages:
|
335 |
with st.chat_message(message["role"]):
|
336 |
st.markdown(message["content"][0])
|
337 |
+
|
338 |
+
# Display new user question.
|
339 |
+
with st.chat_message("user"):
|
340 |
+
st.markdown(user_question)
|
341 |
|
342 |
#这里的session.state就是保存了这个对话会话的一些基本信息和设置
|
343 |
retrieved_chunks_for_user = searchVDB(user_question, st.session_state.embeddings_df, st.session_state.faiss_index)
|
|
|
344 |
prompt = decorate_user_question(user_question, retrieved_chunks_for_user)
|
345 |
st.session_state.messages.append({"role": "user", "content": [user_question, prompt]})
|
346 |
+
|
|
|
347 |
# Display assistant response in chat message container
|
348 |
with st.chat_message("assistant"):
|
349 |
message_placeholder = st.empty()
|