summaryrefslogtreecommitdiffstats
path: root/gui/streamlit_chat_app.py
diff options
context:
space:
mode:
authort.me/xtekky <98614666+xtekky@users.noreply.github.com>2023-05-01 19:25:42 +0200
committerGitHub <noreply@github.com>2023-05-01 19:25:42 +0200
commit5ca2ab6cceda846441bdbe0bdb98829edda4f8eb (patch)
tree648535351f52e0b8a11f96b9a21e0d48bb2e7d29 /gui/streamlit_chat_app.py
parentMerge pull request #345 from sudouser777/feature/delete_poe_account (diff)
parentMerge branch 'xtekky:main' into main (diff)
downloadgpt4free-5ca2ab6cceda846441bdbe0bdb98829edda4f8eb.tar
gpt4free-5ca2ab6cceda846441bdbe0bdb98829edda4f8eb.tar.gz
gpt4free-5ca2ab6cceda846441bdbe0bdb98829edda4f8eb.tar.bz2
gpt4free-5ca2ab6cceda846441bdbe0bdb98829edda4f8eb.tar.lz
gpt4free-5ca2ab6cceda846441bdbe0bdb98829edda4f8eb.tar.xz
gpt4free-5ca2ab6cceda846441bdbe0bdb98829edda4f8eb.tar.zst
gpt4free-5ca2ab6cceda846441bdbe0bdb98829edda4f8eb.zip
Diffstat (limited to 'gui/streamlit_chat_app.py')
-rw-r--r--gui/streamlit_chat_app.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/gui/streamlit_chat_app.py b/gui/streamlit_chat_app.py
index 7eb5a656..99e8428c 100644
--- a/gui/streamlit_chat_app.py
+++ b/gui/streamlit_chat_app.py
@@ -107,20 +107,24 @@ search_query = st.sidebar.text_input("Search Conversations:", value=st.session_s
if search_query:
filtered_conversations = []
- for conversation in st.session_state.conversations:
+ indices = []
+ for idx, conversation in enumerate(st.session_state.conversations):
if search_query in conversation['user_inputs'][0]:
filtered_conversations.append(conversation)
+ indices.append(idx)
+
+ filtered_conversations = list(zip(indices, filtered_conversations))
+ conversations = sorted(filtered_conversations, key=lambda x: Levenshtein.distance(search_query, x[1]['user_inputs'][0]))
- conversations = sorted(filtered_conversations, key=lambda c: Levenshtein.distance(search_query, c['user_inputs'][0]))
sidebar_header = f"Search Results ({len(conversations)})"
else:
- conversations = st.session_state.conversations
+ conversations = enumerate(st.session_state.conversations)
sidebar_header = "Conversation History"
# Sidebar
st.sidebar.header(sidebar_header)
-for idx, conversation in enumerate(conversations):
+for idx, conversation in conversations:
if st.sidebar.button(f"Conversation {idx + 1}: {conversation['user_inputs'][0]}", key=f"sidebar_btn_{idx}"):
st.session_state['selected_conversation'] = idx
st.session_state['current_conversation'] = conversation