Update yay.py
Browse files
yay.py
CHANGED
@@ -240,9 +240,9 @@ with st.sidebar:
|
|
240 |
)
|
241 |
st.markdown("### Steps:")
|
242 |
st.markdown("1. Upload documents.")
|
243 |
-
st.markdown("2. Generate
|
244 |
st.markdown("3. Ask questions.")
|
245 |
-
st.markdown("4. Create
|
246 |
|
247 |
# Streamlit UI
|
248 |
# Sidebar
|
@@ -268,8 +268,8 @@ uploaded_files = st.file_uploader("Upload files (PDF, TXT, CSV)", accept_multipl
|
|
268 |
|
269 |
if st.button("Process Documents"):
|
270 |
if uploaded_files:
|
271 |
-
|
272 |
-
|
273 |
if "successfully" in result:
|
274 |
st.success(result)
|
275 |
else:
|
@@ -277,7 +277,6 @@ if st.button("Process Documents"):
|
|
277 |
else:
|
278 |
st.warning("No files uploaded.")
|
279 |
|
280 |
-
|
281 |
# Step 2: Generate Summaries
|
282 |
st.subheader("Step 2: Generate Summaries")
|
283 |
st.write("Select Summary Language:")
|
@@ -291,13 +290,17 @@ summary_language = st.radio(
|
|
291 |
|
292 |
if st.button("Generate Summary"):
|
293 |
if hasattr(st.session_state.rag_system, "document_text") and st.session_state.rag_system.document_text:
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
297 |
else:
|
298 |
st.info("Please process documents first to generate summaries.")
|
299 |
|
300 |
-
|
301 |
# Step 3: Ask Questions
|
302 |
st.subheader("Step 3: Ask Questions")
|
303 |
st.write("Select Q&A Language:")
|
@@ -313,8 +316,8 @@ if st.session_state.rag_system.qa_chain:
|
|
313 |
history = []
|
314 |
user_question = st.text_input("Ask a question:")
|
315 |
if st.button("Submit Question"):
|
316 |
-
|
317 |
-
|
318 |
for question, answer in history:
|
319 |
st.chat_message("user").write(question)
|
320 |
st.chat_message("assistant").write(answer)
|
@@ -334,7 +337,8 @@ podcast_language = st.radio(
|
|
334 |
|
335 |
if st.session_state.rag_system.document_summary:
|
336 |
if st.button("Generate Podcast"):
|
337 |
-
|
|
|
338 |
if audio_path:
|
339 |
st.text_area("Generated Podcast Script", script, height=200)
|
340 |
st.audio(audio_path, format="audio/mp3")
|
|
|
240 |
)
|
241 |
st.markdown("### Steps:")
|
242 |
st.markdown("1. Upload documents.")
|
243 |
+
st.markdown("2. Generate summary.")
|
244 |
st.markdown("3. Ask questions.")
|
245 |
+
st.markdown("4. Create podcast.")
|
246 |
|
247 |
# Streamlit UI
|
248 |
# Sidebar
|
|
|
268 |
|
269 |
if st.button("Process Documents"):
|
270 |
if uploaded_files:
|
271 |
+
with st.spinner("Processing documents, please wait..."):
|
272 |
+
result = st.session_state.rag_system.process_documents(uploaded_files)
|
273 |
if "successfully" in result:
|
274 |
st.success(result)
|
275 |
else:
|
|
|
277 |
else:
|
278 |
st.warning("No files uploaded.")
|
279 |
|
|
|
280 |
# Step 2: Generate Summaries
|
281 |
st.subheader("Step 2: Generate Summaries")
|
282 |
st.write("Select Summary Language:")
|
|
|
290 |
|
291 |
if st.button("Generate Summary"):
|
292 |
if hasattr(st.session_state.rag_system, "document_text") and st.session_state.rag_system.document_text:
|
293 |
+
with st.spinner("Generating summary, please wait..."):
|
294 |
+
summary = st.session_state.rag_system.generate_summary(st.session_state.rag_system.document_text, summary_language)
|
295 |
+
if summary:
|
296 |
+
st.session_state.rag_system.document_summary = summary
|
297 |
+
st.text_area("Document Summary", summary, height=200)
|
298 |
+
st.success("Summary generated successfully!")
|
299 |
+
else:
|
300 |
+
st.error("Failed to generate summary.")
|
301 |
else:
|
302 |
st.info("Please process documents first to generate summaries.")
|
303 |
|
|
|
304 |
# Step 3: Ask Questions
|
305 |
st.subheader("Step 3: Ask Questions")
|
306 |
st.write("Select Q&A Language:")
|
|
|
316 |
history = []
|
317 |
user_question = st.text_input("Ask a question:")
|
318 |
if st.button("Submit Question"):
|
319 |
+
with st.spinner("Answering your question, please wait..."):
|
320 |
+
history = st.session_state.rag_system.handle_query(user_question, history, qa_language)
|
321 |
for question, answer in history:
|
322 |
st.chat_message("user").write(question)
|
323 |
st.chat_message("assistant").write(answer)
|
|
|
337 |
|
338 |
if st.session_state.rag_system.document_summary:
|
339 |
if st.button("Generate Podcast"):
|
340 |
+
with st.spinner("Generating podcast, please wait..."):
|
341 |
+
script, audio_path = st.session_state.rag_system.create_podcast(podcast_language)
|
342 |
if audio_path:
|
343 |
st.text_area("Generated Podcast Script", script, height=200)
|
344 |
st.audio(audio_path, format="audio/mp3")
|