Skip to content

Commit

Permalink
fix #1519: streamlit-chatbox旧版BUG,但新版有兼容问题,先在webui中作处理,并限定chatbox版本 (#…
Browse files Browse the repository at this point in the history
…1525)

close #1519
  • Loading branch information
liunux4odoo authored Sep 19, 2023
1 parent 46af5b7 commit 6c4598b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_webui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions webui_pages/dialogue/dialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def filter(msg):
"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):
Expand Down Expand Up @@ -163,9 +167,9 @@ def on_kb_change():
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}` 搜索...",
Expand All @@ -181,9 +185,9 @@ def on_kb_change():
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:
Expand Down

0 comments on commit 6c4598b

Please sign in to comment.