修复chat接口报错时信息显示KeyError: 'answer'的Bug (#1399)

Co-authored-by: Light <>
This commit is contained in:
Light 2023-09-07 20:44:21 +08:00 committed by GitHub
parent 54cf79f521
commit f422575a17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -153,9 +153,10 @@ def dialogue_page(api: ApiRequest):
for d in api.knowledge_base_chat(prompt, selected_kb, kb_top_k, score_threshold, history, model=llm_model):
if error_msg := check_error_msg(d): # check whether error occured
st.error(error_msg)
text += d["answer"]
chat_box.update_msg(text, 0)
chat_box.update_msg("\n\n".join(d["docs"]), 1, streaming=False)
else:
text += d["answer"]
chat_box.update_msg(text, 0)
chat_box.update_msg("\n\n".join(d["docs"]), 1, streaming=False)
chat_box.update_msg(text, 0, streaming=False)
elif dialogue_mode == "搜索引擎问答":
chat_box.ai_say([