Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -263,14 +263,25 @@ with st.sidebar:
|
|
| 263 |
st.markdown("4. Create podcasts.")
|
| 264 |
|
| 265 |
# Streamlit UI
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
-
#
|
| 269 |
-
|
| 270 |
-
st.error("The 'OPENAI_API_KEY' environment variable is not set. Please configure it in your hosting environment.")
|
| 271 |
|
| 272 |
-
#
|
| 273 |
-
st.subheader("Step 1: Upload Documents")
|
| 274 |
uploaded_files = st.file_uploader("Upload files (PDF, TXT, CSV)", accept_multiple_files=True)
|
| 275 |
|
| 276 |
if st.button("Process Documents"):
|
|
@@ -284,8 +295,15 @@ if st.button("Process Documents"):
|
|
| 284 |
else:
|
| 285 |
st.warning("No files uploaded.")
|
| 286 |
|
| 287 |
-
#
|
| 288 |
-
st.subheader("Step 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
if st.session_state.rag_system.qa_chain:
|
| 290 |
history = []
|
| 291 |
user_question = st.text_input("Ask a question:")
|
|
@@ -296,10 +314,10 @@ if st.session_state.rag_system.qa_chain:
|
|
| 296 |
st.chat_message("user").write(question)
|
| 297 |
st.chat_message("assistant").write(answer)
|
| 298 |
else:
|
| 299 |
-
st.info("Please process documents
|
| 300 |
|
| 301 |
-
# Podcast
|
| 302 |
-
st.subheader("Step
|
| 303 |
if st.session_state.rag_system.document_summary:
|
| 304 |
if st.button("Generate Podcast"):
|
| 305 |
script, audio_path = st.session_state.rag_system.create_podcast()
|
|
@@ -310,4 +328,4 @@ if st.session_state.rag_system.document_summary:
|
|
| 310 |
else:
|
| 311 |
st.error(script)
|
| 312 |
else:
|
| 313 |
-
st.info("Please process documents
|
|
|
|
| 263 |
st.markdown("4. Create podcasts.")
|
| 264 |
|
| 265 |
# Streamlit UI
|
| 266 |
+
# Sidebar
|
| 267 |
+
with st.sidebar:
|
| 268 |
+
st.title("About")
|
| 269 |
+
st.markdown(
|
| 270 |
+
"""
|
| 271 |
+
This app is inspired by the [RAG_HW HuggingFace Space](https://huggingface.co/spaces/wint543/RAG_HW).
|
| 272 |
+
It allows users to:
|
| 273 |
+
1. Upload and process documents
|
| 274 |
+
2. Generate summaries
|
| 275 |
+
3. Ask questions
|
| 276 |
+
4. Create podcasts
|
| 277 |
+
"""
|
| 278 |
+
)
|
| 279 |
|
| 280 |
+
# Main App
|
| 281 |
+
st.title("Document Analyzer and Podcast Generator")
|
|
|
|
| 282 |
|
| 283 |
+
# Step 1: Upload and Process Documents
|
| 284 |
+
st.subheader("Step 1: Upload and Process Documents")
|
| 285 |
uploaded_files = st.file_uploader("Upload files (PDF, TXT, CSV)", accept_multiple_files=True)
|
| 286 |
|
| 287 |
if st.button("Process Documents"):
|
|
|
|
| 295 |
else:
|
| 296 |
st.warning("No files uploaded.")
|
| 297 |
|
| 298 |
+
# Step 2: Generate Summaries
|
| 299 |
+
st.subheader("Step 2: Generate Summaries")
|
| 300 |
+
if st.session_state.rag_system.document_summary:
|
| 301 |
+
st.text_area("Document Summary", st.session_state.rag_system.document_summary, height=200)
|
| 302 |
+
else:
|
| 303 |
+
st.info("Please process documents first to generate summaries.")
|
| 304 |
+
|
| 305 |
+
# Step 3: Ask Questions
|
| 306 |
+
st.subheader("Step 3: Ask Questions")
|
| 307 |
if st.session_state.rag_system.qa_chain:
|
| 308 |
history = []
|
| 309 |
user_question = st.text_input("Ask a question:")
|
|
|
|
| 314 |
st.chat_message("user").write(question)
|
| 315 |
st.chat_message("assistant").write(answer)
|
| 316 |
else:
|
| 317 |
+
st.info("Please process documents first to enable Q&A.")
|
| 318 |
|
| 319 |
+
# Step 4: Generate Podcast
|
| 320 |
+
st.subheader("Step 4: Generate Podcast")
|
| 321 |
if st.session_state.rag_system.document_summary:
|
| 322 |
if st.button("Generate Podcast"):
|
| 323 |
script, audio_path = st.session_state.rag_system.create_podcast()
|
|
|
|
| 328 |
else:
|
| 329 |
st.error(script)
|
| 330 |
else:
|
| 331 |
+
st.info("Please process documents and generate summaries before creating a podcast.")
|