NavyDevilDoc commited on
Commit
d6d6670
·
verified ·
1 Parent(s): 3e29775

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +18 -3
src/app.py CHANGED
@@ -488,9 +488,24 @@ with tab3:
488
 
489
  if q_ctx:
490
  prompt = quiz.construct_question_generation_prompt(q_ctx["context_text"])
491
- question_text, usage = query_model_universal([{"role": "user", "content": prompt}], 300, model_choice, st.session_state.get("user_openai_key"))
492
- if "UNABLE" not in question_text and len(question_text) > 10:
493
- valid_question_found = True; qs["active"] = True; qs["question_data"] = q_ctx; qs["generated_question_text"] = question_text; qs["feedback"] = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
 
495
  if not valid_question_found:
496
  if focus_topic: st.warning(f"No documents found containing '{focus_topic}'. Try a different keyword.")
 
488
 
489
  if q_ctx:
490
  prompt = quiz.construct_question_generation_prompt(q_ctx["context_text"])
491
+ response_text, usage = query_model_universal([{"role": "user", "content": prompt}], 300, model_choice, st.session_state.get("user_openai_key"))
492
+
493
+ # PARSE OUTPUT
494
+ if "UNABLE" not in response_text and "QUOTE:" in response_text:
495
+ # Split into Question and Quote
496
+ parts = response_text.split("QUOTE:")
497
+ q_text = parts[0].replace("QUESTION:", "").strip()
498
+ quote_text = parts[1].strip()
499
+
500
+ # SAFETY CHECK: Is the quote actually in the text?
501
+ # We use a loose check (in case of minor whitespace diffs)
502
+ # We take the first 20 chars of the quote to verify location
503
+ if quote_text[:20] in q_ctx["context_text"]:
504
+ valid_question_found = True
505
+ qs["active"] = True
506
+ qs["question_data"] = q_ctx
507
+ qs["generated_question_text"] = q_text
508
+ qs["feedback"] = None
509
 
510
  if not valid_question_found:
511
  if focus_topic: st.warning(f"No documents found containing '{focus_topic}'. Try a different keyword.")