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 liunux4odoo
parent be22869c5e
commit b161985d79
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

@ -28,7 +28,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):
@ -183,9 +187,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}` 搜索...",
@ -202,9 +206,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: