Update app.py
Browse files
app.py
CHANGED
|
@@ -316,44 +316,60 @@ with col3:
|
|
| 316 |
st.session_state.session_ids = []
|
| 317 |
st.rerun()
|
| 318 |
|
| 319 |
-
#
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
st.
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
)
|
| 346 |
-
st.
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
|
|
|
|
|
|
|
| 357 |
# Language & Voice Settings Section
|
| 358 |
st.markdown('<div class="section-header">π£οΈ Language & Voice Settings</div>', unsafe_allow_html=True)
|
| 359 |
|
|
|
|
| 316 |
st.session_state.session_ids = []
|
| 317 |
st.rerun()
|
| 318 |
|
| 319 |
+
# Topics Section (Outside form for dynamic interaction)
|
| 320 |
+
st.markdown('<div class="section-header">π Topics Configuration</div>', unsafe_allow_html=True)
|
| 321 |
+
|
| 322 |
+
# Display existing topics with better styling
|
| 323 |
+
for i, topic in enumerate(st.session_state.topics_list):
|
| 324 |
+
st.markdown(f'<div class="topic-container">', unsafe_allow_html=True)
|
| 325 |
+
st.markdown(f'<div class="topic-header">π Topic {i+1}</div>', unsafe_allow_html=True)
|
| 326 |
|
| 327 |
+
col1, col2, col3 = st.columns([3, 3, 1])
|
| 328 |
+
with col1:
|
| 329 |
+
topic_title = st.text_input(
|
| 330 |
+
"Topic Title",
|
| 331 |
+
value=topic["topic_title"],
|
| 332 |
+
key=f"topic_title_{i}",
|
| 333 |
+
help="Enter the topic title"
|
| 334 |
+
)
|
| 335 |
+
st.session_state.topics_list[i]["topic_title"] = topic_title
|
| 336 |
+
|
| 337 |
+
with col2:
|
| 338 |
+
chapter_title = st.text_input(
|
| 339 |
+
"Chapter Title",
|
| 340 |
+
value=topic["chapter_title"],
|
| 341 |
+
key=f"chapter_title_{i}",
|
| 342 |
+
help="Enter the chapter title"
|
| 343 |
+
)
|
| 344 |
+
st.session_state.topics_list[i]["chapter_title"] = chapter_title
|
| 345 |
+
|
| 346 |
+
with col3:
|
| 347 |
+
if len(st.session_state.topics_list) > 1:
|
| 348 |
+
st.markdown("<br>", unsafe_allow_html=True) # Add spacing
|
| 349 |
+
if st.button("ποΈ", key=f"remove_{i}", help="Remove this topic"):
|
| 350 |
+
st.session_state.topics_list.pop(i)
|
| 351 |
+
st.rerun()
|
| 352 |
+
|
| 353 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 354 |
+
|
| 355 |
+
# Add/Remove topic buttons
|
| 356 |
+
st.markdown('<div class="action-buttons">', unsafe_allow_html=True)
|
| 357 |
+
col1, col2, col3, col4 = st.columns([2, 2, 2, 4])
|
| 358 |
+
with col1:
|
| 359 |
+
if st.button("β Add Topic", key="add_topic", help="Add a new topic"):
|
| 360 |
+
st.session_state.topics_list.append({
|
| 361 |
+
"topic_title": f"Topic {len(st.session_state.topics_list) + 1}",
|
| 362 |
+
"chapter_title": f"Chapter {len(st.session_state.topics_list) + 1}"
|
| 363 |
+
})
|
| 364 |
+
st.rerun()
|
| 365 |
+
with col2:
|
| 366 |
+
if st.button("π Reset All", key="reset_topics", help="Reset to default topics"):
|
| 367 |
+
st.session_state.topics_list = [{"topic_title": "What is Flask", "chapter_title": "Introduction to Flask"}]
|
| 368 |
+
st.rerun()
|
| 369 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 370 |
|
| 371 |
+
# Main Form (for settings and submission)
|
| 372 |
+
with st.form("personalization_form", clear_on_submit=False):
|
| 373 |
# Language & Voice Settings Section
|
| 374 |
st.markdown('<div class="section-header">π£οΈ Language & Voice Settings</div>', unsafe_allow_html=True)
|
| 375 |
|