Shubham170793 commited on
Commit
30ffedc
Β·
verified Β·
1 Parent(s): 9aa1aa8

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +31 -10
src/streamlit_app.py CHANGED
@@ -212,7 +212,7 @@ st.caption("Query SAP documentation and enterprise PDFs β€” powered by reasoning
212
  doc_choice = st.radio("Select a document:", ["-- Select --", "Sample PDF", "Upload Custom PDF"], index=0)
213
 
214
  # ==========================================================
215
- # πŸ“‚ DOCUMENT HANDLING β€” CLEAN + ACCURATE UI FLOW (final stable)
216
  # ==========================================================
217
  if doc_choice == "-- Select --":
218
  st.info("⬅️ Select or upload a document to begin.")
@@ -253,13 +253,13 @@ else:
253
  embeddings = cache_embeddings(doc_name, chunks, embed_chunks)
254
  index = build_faiss_index(embeddings)
255
 
256
- final_message = (
257
- "βœ… Document processed successfully β€” hang tight, "
258
- "your AI assistant is gearing up to help you out!"
259
- )
260
- status.success(final_message)
261
 
262
- # Store everything so UI stays consistent on rerun
263
  st.session_state.update({
264
  "text": text,
265
  "toc": toc,
@@ -268,7 +268,7 @@ else:
268
  "index": index,
269
  "doc_ready": True,
270
  "last_doc": doc_name,
271
- "status_text": final_message
272
  })
273
 
274
  # Build suggestions once
@@ -280,14 +280,34 @@ else:
280
  st.rerun()
281
 
282
  else:
283
- # Reuse cached content and status message
284
  text = st.session_state["text"]
285
  toc = st.session_state["toc"]
286
  chunks = st.session_state["chunks"]
287
  embeddings = st.session_state["embeddings"]
288
  index = st.session_state["index"]
289
  query_suggestions = st.session_state.get("query_suggestions_fixed", [])
290
- st.info(st.session_state.get("status_text", f"πŸ“„ {doc_name} is ready for queries."))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
  # --- Ask section ---
293
  st.markdown("### πŸ’¬ Ask the Assistant")
@@ -320,6 +340,7 @@ else:
320
  st.markdown(f"<div class='answer-box'>{answer}</div>", unsafe_allow_html=True)
321
 
322
 
 
323
  # ==========================================================
324
  # 🎨 Optional Sidebar Scroll Styling (keeps it clean)
325
  # ==========================================================
 
212
  doc_choice = st.radio("Select a document:", ["-- Select --", "Sample PDF", "Upload Custom PDF"], index=0)
213
 
214
  # ==========================================================
215
+ # πŸ“‚ DOCUMENT HANDLING β€” CLEAN + ACCURATE UI FLOW (final polished)
216
  # ==========================================================
217
  if doc_choice == "-- Select --":
218
  st.info("⬅️ Select or upload a document to begin.")
 
253
  embeddings = cache_embeddings(doc_name, chunks, embed_chunks)
254
  index = build_faiss_index(embeddings)
255
 
256
+ # βœ… Smooth transition for ready state
257
+ import time
258
+ status.success("βœ… Document processed successfully.")
259
+ time.sleep(1.2)
260
+ status.empty()
261
 
262
+ # βœ… Simplified final ready message for reruns
263
  st.session_state.update({
264
  "text": text,
265
  "toc": toc,
 
268
  "index": index,
269
  "doc_ready": True,
270
  "last_doc": doc_name,
271
+ "status_text": f"πŸ“„ {doc_name} ready β€” your AI assistant is standing by!"
272
  })
273
 
274
  # Build suggestions once
 
280
  st.rerun()
281
 
282
  else:
283
+ # Reuse cached content and show final ready message with fade-in
284
  text = st.session_state["text"]
285
  toc = st.session_state["toc"]
286
  chunks = st.session_state["chunks"]
287
  embeddings = st.session_state["embeddings"]
288
  index = st.session_state["index"]
289
  query_suggestions = st.session_state.get("query_suggestions_fixed", [])
290
+
291
+ # ✨ Fading "ready" message for better UX
292
+ st.markdown(f"""
293
+ <div style="
294
+ animation: fadeIn 1.2s ease-in-out;
295
+ background: #072541;
296
+ border-left: 4px solid #10b981;
297
+ padding: 10px 14px;
298
+ border-radius: 6px;
299
+ color: #d1fae5;
300
+ margin-top: 8px;
301
+ font-size: 15px;">
302
+ βœ… {st.session_state.get('status_text', f"{doc_name} ready for queries.")}
303
+ </div>
304
+ <style>
305
+ @keyframes fadeIn {{
306
+ from {{opacity: 0; transform: translateY(-4px);}}
307
+ to {{opacity: 1; transform: translateY(0);}}
308
+ }}
309
+ </style>
310
+ """, unsafe_allow_html=True)
311
 
312
  # --- Ask section ---
313
  st.markdown("### πŸ’¬ Ask the Assistant")
 
340
  st.markdown(f"<div class='answer-box'>{answer}</div>", unsafe_allow_html=True)
341
 
342
 
343
+
344
  # ==========================================================
345
  # 🎨 Optional Sidebar Scroll Styling (keeps it clean)
346
  # ==========================================================