Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 290 |
-
|
| 291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
st.session_state.
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 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
|