MahatirTusher commited on
Commit
081ab6a
·
verified ·
1 Parent(s): 15493f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -15
app.py CHANGED
@@ -285,23 +285,28 @@ def main():
285
  help="Upload your book or document to start chatting with it"
286
  )
287
 
 
 
288
  if uploaded_file:
289
- with st.sidebar.spinner("Processing document..."):
290
- # Process the uploaded file
291
- chunks = process_uploaded_file(uploaded_file)
 
 
 
 
 
 
292
 
293
- if chunks:
294
- # Create/update the database
295
- st.session_state.chunks = chunks
296
- st.session_state.db = create_chroma_db(chunks)
297
- st.sidebar.success(f" Document processed! Created {len(chunks)} chunks.")
298
-
299
- # Add system message to chat history
300
- if not st.session_state.messages:
301
- st.session_state.messages.append({
302
- "role": "system",
303
- "content": "I've processed your document. You can now ask questions about it!"
304
- })
305
  st.sidebar.markdown("</div>", unsafe_allow_html=True)
306
 
307
  # Clear chat button
 
285
  help="Upload your book or document to start chatting with it"
286
  )
287
 
288
+ processing_placeholder = st.sidebar.empty()
289
+
290
  if uploaded_file:
291
+ processing_placeholder.info("Processing document... Please wait.")
292
+ # Process the uploaded file
293
+ chunks = process_uploaded_file(uploaded_file)
294
+
295
+ if chunks:
296
+ # Create/update the database
297
+ st.session_state.chunks = chunks
298
+ st.session_state.db = create_chroma_db(chunks)
299
+ processing_placeholder.success(f"✅ Document processed! Created {len(chunks)} chunks.")
300
 
301
+ # Add system message to chat history
302
+ if not st.session_state.messages:
303
+ st.session_state.messages.append({
304
+ "role": "system",
305
+ "content": "I've processed your document. You can now ask questions about it!"
306
+ })
307
+ else:
308
+ processing_placeholder.error("Failed to process document.")
309
+
 
 
 
310
  st.sidebar.markdown("</div>", unsafe_allow_html=True)
311
 
312
  # Clear chat button