Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1384,27 +1384,25 @@ def _chat_fragment():
|
|
| 1384 |
)
|
| 1385 |
|
| 1386 |
with st.chat_message("assistant"):
|
| 1387 |
-
container = st.empty()
|
| 1388 |
-
meta_placeholder = st.empty() # 用empty占位,避免提前渲染
|
| 1389 |
-
|
| 1390 |
# 联网模式:大模型 + 网络搜索,不查知识库
|
| 1391 |
# 知识库模式:RAG 检索本地知识库
|
| 1392 |
if _web_on:
|
| 1393 |
-
|
| 1394 |
-
|
| 1395 |
else:
|
| 1396 |
-
|
| 1397 |
-
|
| 1398 |
|
| 1399 |
-
|
|
|
|
| 1400 |
|
| 1401 |
try:
|
| 1402 |
-
full_response =
|
| 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 |
-
|
| 1408 |
st.session_state.messages.append(
|
| 1409 |
{"role": "assistant", "content": full_response, "meta": meta_info}
|
| 1410 |
)
|
|
|
|
| 1384 |
)
|
| 1385 |
|
| 1386 |
with st.chat_message("assistant"):
|
|
|
|
|
|
|
|
|
|
| 1387 |
# 联网模式:大模型 + 网络搜索,不查知识库
|
| 1388 |
# 知识库模式:RAG 检索本地知识库
|
| 1389 |
if _web_on:
|
| 1390 |
+
with st.status("🌐 正在联网搜索...", expanded=False):
|
| 1391 |
+
relevant_docs = []
|
| 1392 |
else:
|
| 1393 |
+
with st.status("🔍 正在搜索知识库...", expanded=False):
|
| 1394 |
+
relevant_docs = search_local(q, _top_k, _threshold)
|
| 1395 |
|
| 1396 |
+
response_container = st.empty()
|
| 1397 |
+
response_container.markdown("*🤔 正在组织语言...*")
|
| 1398 |
|
| 1399 |
try:
|
| 1400 |
+
full_response = response_container.write_stream(
|
| 1401 |
llm_answer(q, relevant_docs, _model_name, _web_on)
|
| 1402 |
)
|
| 1403 |
meta_info = st.session_state.get("last_meta", "")
|
| 1404 |
if meta_info:
|
| 1405 |
+
st.caption(meta_info)
|
| 1406 |
st.session_state.messages.append(
|
| 1407 |
{"role": "assistant", "content": full_response, "meta": meta_info}
|
| 1408 |
)
|