summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authormache102 <bee365go@gmail.com>2023-05-01 16:57:20 +0200
committermache102 <bee365go@gmail.com>2023-05-01 16:57:20 +0200
commit4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d (patch)
tree2f8e407a502a7bed37bc159ccc7527875d95e438 /gui
parentadd searchbar (diff)
downloadgpt4free-4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d.tar
gpt4free-4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d.tar.gz
gpt4free-4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d.tar.bz2
gpt4free-4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d.tar.lz
gpt4free-4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d.tar.xz
gpt4free-4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d.tar.zst
gpt4free-4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d.zip
Diffstat (limited to 'gui')
-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 c5c960a9..f80afa80 100644
--- a/gui/streamlit_chat_app.py
+++ b/gui/streamlit_chat_app.py
@@ -108,20 +108,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