NavyDevilDoc commited on
Commit
5d7db55
·
verified ·
1 Parent(s): 50e3883

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +6 -4
src/app.py CHANGED
@@ -612,7 +612,8 @@ with tab3:
612
  valid_question_found = False
613
  attempts = 0
614
 
615
- while not valid_question_found and attempts < 3:
 
616
  attempts += 1
617
  q_ctx = quiz.get_document_context(st.session_state.username)
618
 
@@ -623,8 +624,9 @@ with tab3:
623
  300, model_choice, st.session_state.get("user_openai_key")
624
  )
625
 
626
- # Filter out skips or empty responses
627
- if "SKIP" not in question_text and len(question_text) > 10:
 
628
  valid_question_found = True
629
  qs["active"] = True
630
  qs["question_data"] = q_ctx
@@ -632,7 +634,7 @@ with tab3:
632
  qs["feedback"] = None
633
 
634
  if not valid_question_found:
635
- st.warning("Tried to find a good engineering question but the available text was too administrative. Try uploading denser technical notes!")
636
 
637
  # 2. AUTO-TRIGGER (Chained Question Logic)
638
  if st.session_state.quiz_trigger:
 
612
  valid_question_found = False
613
  attempts = 0
614
 
615
+ # RETRY LOOP: Increased to 5 attempts to find a good chunk
616
+ while not valid_question_found and attempts < 5:
617
  attempts += 1
618
  q_ctx = quiz.get_document_context(st.session_state.username)
619
 
 
624
  300, model_choice, st.session_state.get("user_openai_key")
625
  )
626
 
627
+ # LOGIC UPDATE: Check for 'UNABLE' instead of 'SKIP'
628
+ # We also check length to ensure we didn't get a blank response
629
+ if "UNABLE" not in question_text and len(question_text) > 10:
630
  valid_question_found = True
631
  qs["active"] = True
632
  qs["question_data"] = q_ctx
 
634
  qs["feedback"] = None
635
 
636
  if not valid_question_found:
637
+ st.warning("Could not generate a question after 5 attempts. The selected documents might be too sparse or formatted as pure data tables.")
638
 
639
  # 2. AUTO-TRIGGER (Chained Question Logic)
640
  if st.session_state.quiz_trigger: