Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -92,16 +92,27 @@ with st.sidebar:
|
|
| 92 |
|
| 93 |
st.markdown("---")
|
| 94 |
if st.button("🗑️ Clear Chat & Reset"):
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
st.markdown("### ℹ️ How to Use")
|
| 107 |
st.info(
|
|
|
|
| 92 |
|
| 93 |
st.markdown("---")
|
| 94 |
if st.button("🗑️ Clear Chat & Reset"):
|
| 95 |
+
try:
|
| 96 |
+
# 1. Attempt Cleanup with visual feedback
|
| 97 |
+
with st.spinner(f"Deleting vector data for {st.session_state.session_id}..."):
|
| 98 |
+
cleanup_session_index(st.session_state.session_id)
|
| 99 |
+
|
| 100 |
+
# 2. Reset Local State (Only if cleanup succeeded)
|
| 101 |
+
st.session_state.session_id = str(uuid.uuid4())
|
| 102 |
+
st.session_state.doc_store = SessionDocStore()
|
| 103 |
+
st.session_state.messages = []
|
| 104 |
+
st.session_state.bm25 = None
|
| 105 |
+
st.session_state.processed_file = None
|
| 106 |
+
st.session_state.uploader_key = str(uuid.uuid4())
|
| 107 |
+
|
| 108 |
+
# 3. Re-attach Janitor for new session
|
| 109 |
+
st.session_state.janitor = SessionJanitor(st.session_state.session_id)
|
| 110 |
+
|
| 111 |
+
st.success("Cache cleared successfully!")
|
| 112 |
+
st.rerun()
|
| 113 |
+
|
| 114 |
+
except Exception as e:
|
| 115 |
+
st.error(f"Cleanup failed! Check Pinecone Console.\nError: {e}")
|
| 116 |
|
| 117 |
st.markdown("### ℹ️ How to Use")
|
| 118 |
st.info(
|