Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,22 +54,30 @@ def analyze_segment_with_gemini(segment_text):
|
|
| 54 |
|
| 55 |
prompt = f"""
|
| 56 |
Analyze the following text and identify distinct segments within it and do text segmentation:
|
| 57 |
-
1. Segments should be STRICTLY max=
|
| 58 |
2. For each segment/topic you identify:
|
| 59 |
- Provide a SPECIFIC and UNIQUE topic name (3-5 words) that clearly differentiates it from other segments
|
| 60 |
- List 3-5 key concepts discussed in that segment (be precise and avoid repetition between segments)
|
| 61 |
- Write a brief summary of that segment (3-5 sentences)
|
| 62 |
-
- Create 5 quiz questions based DIRECTLY on the content in that segment only
|
| 63 |
-
|
|
|
|
| 64 |
For each quiz question:
|
| 65 |
- Create one correct answer that comes DIRECTLY from the text
|
| 66 |
- Create two plausible but incorrect answers
|
| 67 |
- IMPORTANT: Ensure all answer options have similar length (± 3 words)
|
| 68 |
- Ensure the correct answer is clearly indicated with a ✓ symbol
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
Text:
|
| 71 |
{segment_text}
|
| 72 |
-
|
| 73 |
Format your response as JSON with the following structure:
|
| 74 |
{{
|
| 75 |
"segments": [
|
|
@@ -99,8 +107,11 @@ def analyze_segment_with_gemini(segment_text):
|
|
| 99 |
}}
|
| 100 |
]
|
| 101 |
}}
|
| 102 |
-
|
| 103 |
IMPORTANT: Each segment must have a DISTINCT topic name that clearly differentiates it from others.
|
|
|
|
|
|
|
|
|
|
| 104 |
"""
|
| 105 |
|
| 106 |
response = llm.invoke(prompt)
|
|
|
|
| 54 |
|
| 55 |
prompt = f"""
|
| 56 |
Analyze the following text and identify distinct segments within it and do text segmentation:
|
| 57 |
+
1. Segments should be STRICTLY max=15
|
| 58 |
2. For each segment/topic you identify:
|
| 59 |
- Provide a SPECIFIC and UNIQUE topic name (3-5 words) that clearly differentiates it from other segments
|
| 60 |
- List 3-5 key concepts discussed in that segment (be precise and avoid repetition between segments)
|
| 61 |
- Write a brief summary of that segment (3-5 sentences)
|
| 62 |
+
- Create 5 high-quality, meaningful quiz questions based DIRECTLY on the content in that segment only
|
| 63 |
+
- Questions and answers should be only from the content of the segment
|
| 64 |
+
|
| 65 |
For each quiz question:
|
| 66 |
- Create one correct answer that comes DIRECTLY from the text
|
| 67 |
- Create two plausible but incorrect answers
|
| 68 |
- IMPORTANT: Ensure all answer options have similar length (± 3 words)
|
| 69 |
- Ensure the correct answer is clearly indicated with a ✓ symbol
|
| 70 |
+
- Questions should **require actual understanding**, NOT just basic fact recall.
|
| 71 |
+
- Questions Are **non-trivial**, encourage deeper thinking, and **avoid surface-level facts**.
|
| 72 |
+
- Are **directly based on the segment's content** (not inferred from the summary).
|
| 73 |
+
- Do **not include questions about document structure** (e.g., title, number of paragraphs).
|
| 74 |
+
- Do **not generate overly generic or obvious questions** (e.g., "What is mentioned in the text?").
|
| 75 |
+
- Focus on **core ideas, logical reasoning, and conceptual understanding**.
|
| 76 |
+
|
| 77 |
+
|
| 78 |
Text:
|
| 79 |
{segment_text}
|
| 80 |
+
|
| 81 |
Format your response as JSON with the following structure:
|
| 82 |
{{
|
| 83 |
"segments": [
|
|
|
|
| 107 |
}}
|
| 108 |
]
|
| 109 |
}}
|
| 110 |
+
|
| 111 |
IMPORTANT: Each segment must have a DISTINCT topic name that clearly differentiates it from others.
|
| 112 |
+
- **Do NOT repeat** key concepts across multiple segments unless absolutely necessary.
|
| 113 |
+
- **Ensure the quiz questions challenge the reader** and **are not easily guessable**.
|
| 114 |
+
|
| 115 |
"""
|
| 116 |
|
| 117 |
response = llm.invoke(prompt)
|