AlauStone commited on
Commit
68f1665
·
verified ·
1 Parent(s): 5fa0781

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -1385,7 +1385,7 @@ def _chat_fragment():
1385
 
1386
  with st.chat_message("assistant"):
1387
  container = st.empty()
1388
- st.session_state["last_meta"] = "" # 清空旧的meta,避免显示上一次的内容
1389
 
1390
  # 联网模式:大模型 + 网络搜索,不查知识库
1391
  # 知识库模式:RAG 检索本地知识库
@@ -1403,8 +1403,8 @@ def _chat_fragment():
1403
  llm_answer(q, relevant_docs, _model_name, _web_on)
1404
  )
1405
  meta_info = st.session_state.get("last_meta", "")
1406
- if meta_info: # 只在有meta时显示
1407
- st.caption(meta_info)
1408
  st.session_state.messages.append(
1409
  {"role": "assistant", "content": full_response, "meta": meta_info}
1410
  )
 
1385
 
1386
  with st.chat_message("assistant"):
1387
  container = st.empty()
1388
+ meta_placeholder = st.empty() # 用empty占位,避免提前渲染
1389
 
1390
  # 联网模式:大模型 + 网络搜索,不查知识库
1391
  # 知识库模式:RAG 检索本地知识库
 
1403
  llm_answer(q, relevant_docs, _model_name, _web_on)
1404
  )
1405
  meta_info = st.session_state.get("last_meta", "")
1406
+ if meta_info:
1407
+ meta_placeholder.caption(meta_info) # 流式完成后才显示meta
1408
  st.session_state.messages.append(
1409
  {"role": "assistant", "content": full_response, "meta": meta_info}
1410
  )