Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files- src/app.py +20 -2
src/app.py
CHANGED
|
@@ -534,6 +534,25 @@ with tab2:
|
|
| 534 |
|
| 535 |
# DB MANAGER
|
| 536 |
st.subheader("Database Management")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
# This reads from local cache so no index needed
|
| 538 |
docs = rag_engine.list_documents(st.session_state.username)
|
| 539 |
|
|
@@ -545,12 +564,11 @@ with tab2:
|
|
| 545 |
if not st.session_state.active_index:
|
| 546 |
st.error("Select Index first.")
|
| 547 |
else:
|
| 548 |
-
# FIXED: Added index_name parameter
|
| 549 |
rag_engine.delete_document(st.session_state.username, d['source'], st.session_state.active_index)
|
| 550 |
tracker.upload_user_db(st.session_state.username)
|
| 551 |
st.rerun()
|
| 552 |
else:
|
| 553 |
-
st.
|
| 554 |
|
| 555 |
# === TAB 3: QUIZ MODE ===
|
| 556 |
with tab3:
|
|
|
|
| 534 |
|
| 535 |
# DB MANAGER
|
| 536 |
st.subheader("Database Management")
|
| 537 |
+
# 1. RESYNC BUTTON (The Fix)
|
| 538 |
+
col_db_1, col_db_2 = st.columns([2, 1])
|
| 539 |
+
with col_db_1:
|
| 540 |
+
st.info("If Quiz Mode is failing, your local files might be missing (due to restart).")
|
| 541 |
+
with col_db_2:
|
| 542 |
+
if st.button("🔄 Resync from Pinecone"):
|
| 543 |
+
if not st.session_state.active_index:
|
| 544 |
+
st.error("Select Index first.")
|
| 545 |
+
else:
|
| 546 |
+
with st.spinner("Downloading memories from Pinecone..."):
|
| 547 |
+
ok, msg = rag_engine.rebuild_cache_from_pinecone(
|
| 548 |
+
st.session_state.username,
|
| 549 |
+
st.session_state.active_index
|
| 550 |
+
)
|
| 551 |
+
if ok: st.success(msg); time.sleep(1); st.rerun()
|
| 552 |
+
else: st.error(msg)
|
| 553 |
+
st.divider()
|
| 554 |
+
|
| 555 |
+
# 2. FILE LIST
|
| 556 |
# This reads from local cache so no index needed
|
| 557 |
docs = rag_engine.list_documents(st.session_state.username)
|
| 558 |
|
|
|
|
| 564 |
if not st.session_state.active_index:
|
| 565 |
st.error("Select Index first.")
|
| 566 |
else:
|
|
|
|
| 567 |
rag_engine.delete_document(st.session_state.username, d['source'], st.session_state.active_index)
|
| 568 |
tracker.upload_user_db(st.session_state.username)
|
| 569 |
st.rerun()
|
| 570 |
else:
|
| 571 |
+
st.warning("Local Cache Empty. Click 'Resync' above if you have data in Pinecone.")
|
| 572 |
|
| 573 |
# === TAB 3: QUIZ MODE ===
|
| 574 |
with tab3:
|