banao-tech commited on
Commit
d90c34f
Β·
verified Β·
1 Parent(s): 6a8ccf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -13
app.py CHANGED
@@ -267,6 +267,11 @@ if 'authenticated' not in st.session_state:
267
  if not st.session_state.authenticated:
268
  st.markdown('<h1 class="main-header">πŸ” Login to Course Personalization</h1>', unsafe_allow_html=True)
269
 
 
 
 
 
 
270
  col1, col2, col3 = st.columns([1, 2, 1])
271
  with col2:
272
  with st.container():
@@ -281,7 +286,7 @@ if not st.session_state.authenticated:
281
  login_submitted = st.form_submit_button("πŸš€ Login", use_container_width=True)
282
 
283
  if login_submitted:
284
- if username == VALID_USERNAME and password == VALID_PASSWORD:
285
  st.session_state.authenticated = True
286
  st.success("Login successful! Redirecting...")
287
  time.sleep(1)
@@ -292,9 +297,9 @@ if not st.session_state.authenticated:
292
  st.markdown('</div>', unsafe_allow_html=True)
293
 
294
  st.markdown("---")
295
- st.markdown(f"""
296
  <div style="text-align: center; color: #888888;">
297
- <small>Demo Credentials: {VALID_USERNAME} / {VALID_PASSWORD if len(VALID_PASSWORD) <= 10 else VALID_PASSWORD[:3] + '...'}</small>
298
  </div>
299
  """, unsafe_allow_html=True)
300
  st.stop()
@@ -397,8 +402,8 @@ with st.form("personalization_form", clear_on_submit=False):
397
  with col3:
398
  tts_voice = st.selectbox(
399
  "Voice Style",
400
- ["onyx", "echo", "soprano", "alto", "robotic"],
401
- index=0,
402
  format_func=lambda x: x.capitalize(),
403
  help="Select the voice style for text-to-speech"
404
  )
@@ -430,14 +435,14 @@ if topic_mode == "Multiple Topics":
430
  st.markdown('<div class="action-buttons">', unsafe_allow_html=True)
431
  col1, col2, col3, col4 = st.columns([2, 2, 2, 4])
432
  with col1:
433
- if st.button(" Add Topic", key="add_topic", help="Add a new topic"):
434
  st.session_state.topics_list.append({
435
  "topic_title": f"Topic {len(st.session_state.topics_list) + 1}",
436
  "chapter_title": f"Chapter {len(st.session_state.topics_list) + 1}"
437
  })
438
  st.rerun()
439
  with col2:
440
- if st.button(" Reset All", key="reset_topics", help="Reset to default topics"):
441
  st.session_state.topics_list = [{"topic_title": "What is Flask", "chapter_title": "Introduction to Flask"}]
442
  st.rerun()
443
  st.markdown('</div>', unsafe_allow_html=True)
@@ -542,13 +547,13 @@ if submitted:
542
  response_data = response.json()
543
  session_ids = response_data.get("session_ids", [])
544
 
545
- st.success(" Base Course started successfully!")
546
 
547
  # Store session IDs in session state
548
  st.session_state.session_ids.extend(session_ids)
549
 
550
  # Display results in a clean format
551
- st.markdown("### Generation Summary")
552
 
553
  col1, col2 = st.columns(2)
554
  with col1:
@@ -564,22 +569,27 @@ if submitted:
564
  **Hinglish**: {"Enabled" if toggle_hinglish else "Disabled"}
565
  """)
566
 
 
 
 
 
 
567
 
568
 
569
 
570
  else:
571
- st.error(f" API Error: {response.status_code}")
572
  if response.text:
573
  st.error(f"**Error Details**: {response.text}")
574
 
575
  except requests.exceptions.Timeout:
576
- st.error(" Request timed out. Please try again later.")
577
  except requests.exceptions.ConnectionError:
578
  st.error("🌐 Connection error. Please check your internet connection.")
579
  except Exception as e:
580
- st.error(f" API call failed: {str(e)}")
581
 
582
  # Show payload for debugging
583
  with st.expander("πŸ› Debug Information", expanded=False):
584
  st.warning("Request payload for debugging:")
585
- st.json(payload)
 
267
  if not st.session_state.authenticated:
268
  st.markdown('<h1 class="main-header">πŸ” Login to Course Personalization</h1>', unsafe_allow_html=True)
269
 
270
+ # Check if credentials are configured
271
+ if not VALID_USERNAME or not VALID_PASSWORD:
272
+ st.error("❌ Authentication credentials not configured. Please contact administrator.")
273
+ st.stop()
274
+
275
  col1, col2, col3 = st.columns([1, 2, 1])
276
  with col2:
277
  with st.container():
 
286
  login_submitted = st.form_submit_button("πŸš€ Login", use_container_width=True)
287
 
288
  if login_submitted:
289
+ if VALID_USERNAME and VALID_PASSWORD and username == VALID_USERNAME and password == VALID_PASSWORD:
290
  st.session_state.authenticated = True
291
  st.success("Login successful! Redirecting...")
292
  time.sleep(1)
 
297
  st.markdown('</div>', unsafe_allow_html=True)
298
 
299
  st.markdown("---")
300
+ st.markdown("""
301
  <div style="text-align: center; color: #888888;">
302
+ <small>Please contact administrator for access credentials</small>
303
  </div>
304
  """, unsafe_allow_html=True)
305
  st.stop()
 
402
  with col3:
403
  tts_voice = st.selectbox(
404
  "Voice Style",
405
+ ["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
406
+ index=3, # Default to "onyx"
407
  format_func=lambda x: x.capitalize(),
408
  help="Select the voice style for text-to-speech"
409
  )
 
435
  st.markdown('<div class="action-buttons">', unsafe_allow_html=True)
436
  col1, col2, col3, col4 = st.columns([2, 2, 2, 4])
437
  with col1:
438
+ if st.button("βž• Add Topic", key="add_topic", help="Add a new topic"):
439
  st.session_state.topics_list.append({
440
  "topic_title": f"Topic {len(st.session_state.topics_list) + 1}",
441
  "chapter_title": f"Chapter {len(st.session_state.topics_list) + 1}"
442
  })
443
  st.rerun()
444
  with col2:
445
+ if st.button("πŸ”„ Reset All", key="reset_topics", help="Reset to default topics"):
446
  st.session_state.topics_list = [{"topic_title": "What is Flask", "chapter_title": "Introduction to Flask"}]
447
  st.rerun()
448
  st.markdown('</div>', unsafe_allow_html=True)
 
547
  response_data = response.json()
548
  session_ids = response_data.get("session_ids", [])
549
 
550
+ st.success("πŸŽ‰ Base Course started successfully!")
551
 
552
  # Store session IDs in session state
553
  st.session_state.session_ids.extend(session_ids)
554
 
555
  # Display results in a clean format
556
+ st.markdown("### πŸ“Š Generation Summary")
557
 
558
  col1, col2 = st.columns(2)
559
  with col1:
 
569
  **Hinglish**: {"Enabled" if toggle_hinglish else "Disabled"}
570
  """)
571
 
572
+ # Display session IDs
573
+ if session_ids:
574
+ st.markdown("### πŸ” Session Tracking IDs")
575
+ for i, session_id in enumerate(session_ids, 1):
576
+ st.markdown(f'<div class="session-info">πŸ“ <strong>Session {i}:</strong> <code>{session_id}</code></div>', unsafe_allow_html=True)
577
 
578
 
579
 
580
  else:
581
+ st.error(f"❌ API Error: {response.status_code}")
582
  if response.text:
583
  st.error(f"**Error Details**: {response.text}")
584
 
585
  except requests.exceptions.Timeout:
586
+ st.error("⏰ Request timed out. Please try again later.")
587
  except requests.exceptions.ConnectionError:
588
  st.error("🌐 Connection error. Please check your internet connection.")
589
  except Exception as e:
590
+ st.error(f"❌ API call failed: {str(e)}")
591
 
592
  # Show payload for debugging
593
  with st.expander("πŸ› Debug Information", expanded=False):
594
  st.warning("Request payload for debugging:")
595
+ st.json(payload)