Update app.py
Browse files
app.py
CHANGED
|
@@ -262,27 +262,6 @@ with st.sidebar:
|
|
| 262 |
st.markdown("3. Ask questions.")
|
| 263 |
st.markdown("4. Create podcasts.")
|
| 264 |
|
| 265 |
-
|
| 266 |
-
# Sidebar: Language Selection
|
| 267 |
-
with st.sidebar:
|
| 268 |
-
st.title("Settings")
|
| 269 |
-
summary_language = st.radio(
|
| 270 |
-
"Select Summary Language:",
|
| 271 |
-
["English", "Spanish", "French", "German", "Chinese"],
|
| 272 |
-
index=0
|
| 273 |
-
)
|
| 274 |
-
qa_language = st.radio(
|
| 275 |
-
"Select Q&A Language:",
|
| 276 |
-
["English", "Spanish", "French", "German", "Chinese"],
|
| 277 |
-
index=0
|
| 278 |
-
)
|
| 279 |
-
podcast_language = st.radio(
|
| 280 |
-
"Select Podcast Language:",
|
| 281 |
-
["English", "Spanish", "French", "German", "Chinese"],
|
| 282 |
-
index=0
|
| 283 |
-
)
|
| 284 |
-
|
| 285 |
-
|
| 286 |
# Streamlit UI
|
| 287 |
# Sidebar
|
| 288 |
#with st.sidebar:
|
|
@@ -318,19 +297,34 @@ if st.button("Process Documents"):
|
|
| 318 |
|
| 319 |
# Step 2: Generate Summaries
|
| 320 |
st.subheader("Step 2: Generate Summaries")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
if st.session_state.rag_system.document_summary:
|
| 322 |
st.text_area("Document Summary", st.session_state.rag_system.document_summary, height=200)
|
| 323 |
else:
|
| 324 |
st.info("Please process documents first to generate summaries.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
# Step 3: Ask Questions
|
| 327 |
st.subheader("Step 3: Ask Questions")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
if st.session_state.rag_system.qa_chain:
|
| 329 |
history = []
|
| 330 |
user_question = st.text_input("Ask a question:")
|
| 331 |
if st.button("Submit Question"):
|
| 332 |
# Handle the user query
|
| 333 |
-
history = st.session_state.rag_system.handle_query(user_question, history)
|
| 334 |
for question, answer in history:
|
| 335 |
st.chat_message("user").write(question)
|
| 336 |
st.chat_message("assistant").write(answer)
|
|
@@ -339,9 +333,14 @@ else:
|
|
| 339 |
|
| 340 |
# Step 4: Generate Podcast
|
| 341 |
st.subheader("Step 4: Generate Podcast")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
if st.session_state.rag_system.document_summary:
|
| 343 |
if st.button("Generate Podcast"):
|
| 344 |
-
script, audio_path = st.session_state.rag_system.create_podcast()
|
| 345 |
if audio_path:
|
| 346 |
st.text_area("Generated Podcast Script", script, height=200)
|
| 347 |
st.audio(audio_path, format="audio/mp3")
|
|
@@ -349,4 +348,4 @@ if st.session_state.rag_system.document_summary:
|
|
| 349 |
else:
|
| 350 |
st.error(script)
|
| 351 |
else:
|
| 352 |
-
st.info("Please process documents and generate summaries before creating a podcast.")
|
|
|
|
| 262 |
st.markdown("3. Ask questions.")
|
| 263 |
st.markdown("4. Create podcasts.")
|
| 264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
# Streamlit UI
|
| 266 |
# Sidebar
|
| 267 |
#with st.sidebar:
|
|
|
|
| 297 |
|
| 298 |
# Step 2: Generate Summaries
|
| 299 |
st.subheader("Step 2: Generate Summaries")
|
| 300 |
+
summary_language = st.radio(
|
| 301 |
+
"Select Summary Language:",
|
| 302 |
+
["English", "Spanish", "French", "German", "Chinese"],
|
| 303 |
+
index=0
|
| 304 |
+
)
|
| 305 |
if st.session_state.rag_system.document_summary:
|
| 306 |
st.text_area("Document Summary", st.session_state.rag_system.document_summary, height=200)
|
| 307 |
else:
|
| 308 |
st.info("Please process documents first to generate summaries.")
|
| 309 |
+
if st.button("Generate Summary"):
|
| 310 |
+
st.session_state.rag_system.document_summary = st.session_state.rag_system.generate_summary(
|
| 311 |
+
st.session_state.rag_system.document_summary,
|
| 312 |
+
summary_language
|
| 313 |
+
)
|
| 314 |
|
| 315 |
# Step 3: Ask Questions
|
| 316 |
st.subheader("Step 3: Ask Questions")
|
| 317 |
+
qa_language = st.radio(
|
| 318 |
+
"Select Q&A Language:",
|
| 319 |
+
["English", "Spanish", "French", "German", "Chinese"],
|
| 320 |
+
index=0
|
| 321 |
+
)
|
| 322 |
if st.session_state.rag_system.qa_chain:
|
| 323 |
history = []
|
| 324 |
user_question = st.text_input("Ask a question:")
|
| 325 |
if st.button("Submit Question"):
|
| 326 |
# Handle the user query
|
| 327 |
+
history = st.session_state.rag_system.handle_query(user_question, history, qa_language)
|
| 328 |
for question, answer in history:
|
| 329 |
st.chat_message("user").write(question)
|
| 330 |
st.chat_message("assistant").write(answer)
|
|
|
|
| 333 |
|
| 334 |
# Step 4: Generate Podcast
|
| 335 |
st.subheader("Step 4: Generate Podcast")
|
| 336 |
+
podcast_language = st.radio(
|
| 337 |
+
"Select Podcast Language:",
|
| 338 |
+
["English", "Spanish", "French", "German", "Chinese"],
|
| 339 |
+
index=0
|
| 340 |
+
)
|
| 341 |
if st.session_state.rag_system.document_summary:
|
| 342 |
if st.button("Generate Podcast"):
|
| 343 |
+
script, audio_path = st.session_state.rag_system.create_podcast(podcast_language)
|
| 344 |
if audio_path:
|
| 345 |
st.text_area("Generated Podcast Script", script, height=200)
|
| 346 |
st.audio(audio_path, format="audio/mp3")
|
|
|
|
| 348 |
else:
|
| 349 |
st.error(script)
|
| 350 |
else:
|
| 351 |
+
st.info("Please process documents and generate summaries before creating a podcast.")
|