Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -74,8 +74,6 @@ def save_conversation():
|
|
74 |
if isinstance(conversation_data, dict):
|
75 |
json.dump(conversation_data, f)
|
76 |
f.write("\n")
|
77 |
-
else:
|
78 |
-
print("Warning: Attempted to save a non-dictionary conversation_data:", conversation_data)
|
79 |
|
80 |
# Function to load previous conversations
|
81 |
def load_conversations():
|
@@ -161,13 +159,16 @@ if st.session_state.show_conversations:
|
|
161 |
if conversations:
|
162 |
selected_indices = []
|
163 |
for i, conv in enumerate(conversations):
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
171 |
|
172 |
if st.sidebar.button("Delete Selected Conversations"):
|
173 |
if selected_indices:
|
|
|
74 |
if isinstance(conversation_data, dict):
|
75 |
json.dump(conversation_data, f)
|
76 |
f.write("\n")
|
|
|
|
|
77 |
|
78 |
# Function to load previous conversations
|
79 |
def load_conversations():
|
|
|
159 |
if conversations:
|
160 |
selected_indices = []
|
161 |
for i, conv in enumerate(conversations):
|
162 |
+
if isinstance(conv, dict): # Ensure conv is a dictionary
|
163 |
+
st.sidebar.write(f"Conversation {i + 1}:")
|
164 |
+
for message in conv.get('messages', []): # Use get safely
|
165 |
+
st.sidebar.write(f"{message['role']}: {message['content']}")
|
166 |
+
st.sidebar.write(f"Files: {', '.join(conv.get('file_names', []))}")
|
167 |
+
# Checkbox for selecting conversation to delete
|
168 |
+
if st.sidebar.checkbox(f"Select Conversation {i + 1} for Deletion", key=f"delete_checkbox_{i}"):
|
169 |
+
selected_indices.append(i)
|
170 |
+
else:
|
171 |
+
print("Warning: Encountered a non-dictionary conversation:", conv)
|
172 |
|
173 |
if st.sidebar.button("Delete Selected Conversations"):
|
174 |
if selected_indices:
|