Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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