banao-tech commited on
Commit
fde10e9
Β·
verified Β·
1 Parent(s): 65d60ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -36
app.py CHANGED
@@ -316,44 +316,60 @@ with col3:
316
  st.session_state.session_ids = []
317
  st.rerun()
318
 
319
- # Main Form
320
- with st.form("personalization_form", clear_on_submit=False):
321
- # Topics Section
322
- st.markdown('<div class="section-header">πŸ“‹ Topics Configuration</div>', unsafe_allow_html=True)
 
 
 
323
 
324
- # Display existing topics with better styling
325
- for i, topic in enumerate(st.session_state.topics_list):
326
- st.markdown(f'<div class="topic-container">', unsafe_allow_html=True)
327
- st.markdown(f'<div class="topic-header">πŸ“– Topic {i+1}</div>', unsafe_allow_html=True)
328
-
329
- col1, col2, col3 = st.columns([3, 3, 1])
330
- with col1:
331
- topic_title = st.text_input(
332
- "Topic Title",
333
- value=topic["topic_title"],
334
- key=f"topic_title_{i}",
335
- help="Enter the topic title"
336
- )
337
- st.session_state.topics_list[i]["topic_title"] = topic_title
338
-
339
- with col2:
340
- chapter_title = st.text_input(
341
- "Chapter Title",
342
- value=topic["chapter_title"],
343
- key=f"chapter_title_{i}",
344
- help="Enter the chapter title"
345
- )
346
- st.session_state.topics_list[i]["chapter_title"] = chapter_title
347
-
348
- with col3:
349
- if len(st.session_state.topics_list) > 1:
350
- st.markdown("<br>", unsafe_allow_html=True) # Add spacing
351
- if st.button("πŸ—‘οΈ", key=f"remove_{i}", help="Remove this topic"):
352
- st.session_state.topics_list.pop(i)
353
- st.rerun()
354
-
355
- st.markdown('</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
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