Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -79,7 +79,7 @@ REQUIRED_FIELDS = [
|
|
79 |
"exam_type", "content_type", "exam_section", "domain", "subdomain",
|
80 |
"topic", "difficulty_level", "reading_passage", "question_text",
|
81 |
"option_a", "option_b", "option_c", "option_d", "correct_answer",
|
82 |
-
"explanation", "is_active"
|
83 |
]
|
84 |
|
85 |
class ExamQuestion(BaseModel):
|
@@ -99,6 +99,7 @@ class ExamQuestion(BaseModel):
|
|
99 |
option_d: str
|
100 |
correct_answer: str
|
101 |
explanation: str
|
|
|
102 |
is_active: bool = True
|
103 |
|
104 |
class ExamQuestionResponse(BaseModel):
|
@@ -470,6 +471,7 @@ ABSOLUTELY CRITICAL:
|
|
470 |
8. The response should be PURE JSON - nothing else
|
471 |
9. SKIP ANY QUESTIONS that refer to images, diagrams, graphs, figures, or visual elements
|
472 |
10. If a question mentions "look at the image", "in the picture", "as shown in", etc., DO NOT include it
|
|
|
473 |
|
474 |
Text to process:
|
475 |
{text}
|
@@ -495,6 +497,7 @@ Format EVERY question using this exact JSON structure:
|
|
495 |
"option_d": "exact_option_d_from_text",
|
496 |
"correct_answer": "one_of[A,B,C,D]_determined_from_context",
|
497 |
"explanation": "explanation_from_text_or_generate_based_on_answer",
|
|
|
498 |
"is_active": true
|
499 |
}}"""
|
500 |
|
@@ -562,7 +565,8 @@ Format EVERY question using this exact JSON structure:
|
|
562 |
"difficulty_level": "Medium",
|
563 |
"reading_passage_title": None,
|
564 |
"is_active": True,
|
565 |
-
"source_file": source_file
|
|
|
566 |
}
|
567 |
|
568 |
for q_idx, q in enumerate(questions, 1):
|
@@ -581,7 +585,8 @@ Format EVERY question using this exact JSON structure:
|
|
581 |
"option_c",
|
582 |
"option_d",
|
583 |
"correct_answer",
|
584 |
-
"explanation"
|
|
|
585 |
]
|
586 |
|
587 |
# Validate critical fields
|
@@ -1387,6 +1392,16 @@ def display_question(question, index):
|
|
1387 |
with col_e:
|
1388 |
st.markdown(f"**Source:** {question.get('source_file', 'N/A')}")
|
1389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1390 |
# Reading passage if available
|
1391 |
if question.get('reading_passage'):
|
1392 |
st.markdown("### π Reading Passage")
|
|
|
79 |
"exam_type", "content_type", "exam_section", "domain", "subdomain",
|
80 |
"topic", "difficulty_level", "reading_passage", "question_text",
|
81 |
"option_a", "option_b", "option_c", "option_d", "correct_answer",
|
82 |
+
"explanation", "is_active", "source_text"
|
83 |
]
|
84 |
|
85 |
class ExamQuestion(BaseModel):
|
|
|
99 |
option_d: str
|
100 |
correct_answer: str
|
101 |
explanation: str
|
102 |
+
source_text: str # The original text from which the question was generated
|
103 |
is_active: bool = True
|
104 |
|
105 |
class ExamQuestionResponse(BaseModel):
|
|
|
471 |
8. The response should be PURE JSON - nothing else
|
472 |
9. SKIP ANY QUESTIONS that refer to images, diagrams, graphs, figures, or visual elements
|
473 |
10. If a question mentions "look at the image", "in the picture", "as shown in", etc., DO NOT include it
|
474 |
+
11. For each question, include the specific source text that the question is based on
|
475 |
|
476 |
Text to process:
|
477 |
{text}
|
|
|
497 |
"option_d": "exact_option_d_from_text",
|
498 |
"correct_answer": "one_of[A,B,C,D]_determined_from_context",
|
499 |
"explanation": "explanation_from_text_or_generate_based_on_answer",
|
500 |
+
"source_text": "exact_text_snippet_that_this_question_is_based_on",
|
501 |
"is_active": true
|
502 |
}}"""
|
503 |
|
|
|
565 |
"difficulty_level": "Medium",
|
566 |
"reading_passage_title": None,
|
567 |
"is_active": True,
|
568 |
+
"source_file": source_file,
|
569 |
+
"source_text": text # Add default source text
|
570 |
}
|
571 |
|
572 |
for q_idx, q in enumerate(questions, 1):
|
|
|
585 |
"option_c",
|
586 |
"option_d",
|
587 |
"correct_answer",
|
588 |
+
"explanation",
|
589 |
+
"source_text" # Add source_text as a critical field
|
590 |
]
|
591 |
|
592 |
# Validate critical fields
|
|
|
1392 |
with col_e:
|
1393 |
st.markdown(f"**Source:** {question.get('source_file', 'N/A')}")
|
1394 |
|
1395 |
+
# Source text if available
|
1396 |
+
if question.get('source_text'):
|
1397 |
+
st.markdown("### π Source Text")
|
1398 |
+
st.markdown(
|
1399 |
+
f"""<div style='background-color: #e8f4f9; padding: 20px; border-radius: 10px; margin: 10px 0; color: #1f1f1f;'>
|
1400 |
+
{question['source_text']}
|
1401 |
+
</div>""",
|
1402 |
+
unsafe_allow_html=True
|
1403 |
+
)
|
1404 |
+
|
1405 |
# Reading passage if available
|
1406 |
if question.get('reading_passage'):
|
1407 |
st.markdown("### π Reading Passage")
|