fix #1519: streamlit-chatbox旧版BUG,但新版有兼容问题,先在webui中作处理,并限定chatbox版本 (#1525)

close #1519
This commit is contained in:
liunux4odoo 2023-09-19 10:09:40 +08:00 committed by GitHub
parent 46af5b7571
commit 6c4598b356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

View File

@ -34,7 +34,7 @@ pandas~=2.0.3
streamlit>=1.26.0
streamlit-option-menu>=0.3.6
streamlit-antd-components>=0.1.11
streamlit-chatbox>=1.1.6
streamlit-chatbox >=1.1.6, <=1.1.7
streamlit-aggrid>=0.3.4.post3
httpx~=0.24.1
watchdog

View File

@ -3,7 +3,7 @@ pandas~=2.0.3
streamlit>=1.26.0
streamlit-option-menu>=0.3.6
streamlit-antd-components>=0.1.11
streamlit-chatbox>=1.1.6
streamlit-chatbox >=1.1.6, <=1.1.7
streamlit-aggrid>=0.3.4.post3
httpx~=0.24.1
nltk

View File

@ -29,7 +29,11 @@ def get_messages_history(history_len: int) -> List[Dict]:
"content": content[0] if content else "",
}
history = chat_box.filter_history(100000, filter) # workaround before upgrading streamlit-chatbox.
# workaround before upgrading streamlit-chatbox.
def stop(h):
return False
history = chat_box.filter_history(history_len=100000, filter=filter, stop=stop)
user_count = 0
i = 1
for i in range(1, len(history) + 1):
@ -163,9 +167,9 @@ def dialogue_page(api: ApiRequest):
st.error(error_msg)
elif chunk := d.get("answer"):
text += chunk
chat_box.update_msg(text, 0)
chat_box.update_msg(text, 0, streaming=False)
chat_box.update_msg("\n\n".join(d.get("docs", [])), 1, streaming=False)
chat_box.update_msg(text, element_index=0)
chat_box.update_msg(text, element_index=0, streaming=False)
chat_box.update_msg("\n\n".join(d.get("docs", [])), element_index=1, streaming=False)
elif dialogue_mode == "搜索引擎问答":
chat_box.ai_say([
f"正在执行 `{search_engine}` 搜索...",
@ -181,9 +185,9 @@ def dialogue_page(api: ApiRequest):
st.error(error_msg)
elif chunk := d.get("answer"):
text += chunk
chat_box.update_msg(text, 0)
chat_box.update_msg(text, 0, streaming=False)
chat_box.update_msg("\n\n".join(d.get("docs", [])), 1, streaming=False)
chat_box.update_msg(text, element_index=0)
chat_box.update_msg(text, element_index=0, streaming=False)
chat_box.update_msg("\n\n".join(d.get("docs", [])), element_index=1, streaming=False)
now = datetime.now()
with st.sidebar: