Spaces:
Sleeping
Sleeping
improving prompt
Browse files
app.py
CHANGED
@@ -162,20 +162,19 @@ def analyze_segment_with_gemini(cluster_text, is_full_text=False):
|
|
162 |
|
163 |
if is_full_text:
|
164 |
prompt = f"""
|
165 |
-
Analyze the following text (likely a transcript or document) and:
|
166 |
-
|
167 |
FIRST ASSESS THE TEXT:
|
168 |
- Check if it's primarily self-introduction, biographical information, or conclusion
|
169 |
- Check if it's too short or lacks meaningful content (less than 100 words of substance)
|
170 |
- If either case is true, respond with a simple JSON: {{"status": "insufficient", "reason": "Brief explanation"}}
|
|
|
|
|
171 |
|
172 |
-
|
173 |
-
1. Identify DISTINCT key topics within the text
|
174 |
2. For each segment/topic you identify:
|
175 |
- Provide a SPECIFIC and UNIQUE topic name (3-5 words) that clearly differentiates it from other segments
|
176 |
- List 3-5 key concepts discussed in that segment
|
177 |
- Write a brief summary of that segment (3-5 sentences)
|
178 |
-
- Create 5 quiz questions based DIRECTLY on the content in that segment
|
179 |
|
180 |
For each quiz question:
|
181 |
- Create one correct answer that comes DIRECTLY from the text
|
@@ -188,7 +187,6 @@ def analyze_segment_with_gemini(cluster_text, is_full_text=False):
|
|
188 |
|
189 |
Format your response as JSON with the following structure:
|
190 |
{{
|
191 |
-
"status": "processed",
|
192 |
"segments": [
|
193 |
{{
|
194 |
"topic_name": "Name of segment 1",
|
@@ -218,32 +216,24 @@ def analyze_segment_with_gemini(cluster_text, is_full_text=False):
|
|
218 |
// More segments...
|
219 |
]
|
220 |
}}
|
221 |
-
|
222 |
-
OR if the text is just introductory, concluding, or insufficient:
|
223 |
-
{{
|
224 |
-
"status": "insufficient",
|
225 |
-
"reason": "Brief explanation of why (e.g., 'Text is primarily self-introduction', 'Text is too short', etc.)"
|
226 |
-
}}
|
227 |
"""
|
228 |
else:
|
229 |
prompt = f"""
|
230 |
-
Analyze the following text segment and:
|
231 |
-
|
232 |
FIRST ASSESS THE TEXT:
|
233 |
- Check if it's primarily self-introduction, biographical information, or conclusion
|
234 |
- Check if it's too short or lacks meaningful content (less than 100 words of substance)
|
235 |
- If either case is true, respond with a simple JSON: {{"status": "insufficient", "reason": "Brief explanation"}}
|
236 |
-
|
237 |
-
|
238 |
1. A SPECIFIC and DESCRIPTIVE topic name (3-5 words) that precisely captures the main focus
|
239 |
2. 3-5 key concepts discussed
|
240 |
3. A brief summary (6-7 sentences)
|
241 |
-
4. Create 5 quiz questions based DIRECTLY on the text content (not from your summary)
|
242 |
|
243 |
For each quiz question:
|
244 |
- Create one correct answer that comes DIRECTLY from the text
|
245 |
- Create two plausible but incorrect answers
|
246 |
-
- IMPORTANT: Ensure all answer options have similar length (± 3 words)
|
247 |
- Ensure the correct answer is clearly indicated
|
248 |
|
249 |
Text segment:
|
@@ -251,7 +241,6 @@ def analyze_segment_with_gemini(cluster_text, is_full_text=False):
|
|
251 |
|
252 |
Format your response as JSON with the following structure:
|
253 |
{{
|
254 |
-
"status": "processed",
|
255 |
"topic_name": "Name of the topic",
|
256 |
"key_concepts": ["concept1", "concept2", "concept3"],
|
257 |
"summary": "Brief summary of the text segment.",
|
@@ -276,12 +265,6 @@ def analyze_segment_with_gemini(cluster_text, is_full_text=False):
|
|
276 |
// More questions...
|
277 |
]
|
278 |
}}
|
279 |
-
|
280 |
-
OR if the text is just introductory, concluding, or insufficient:
|
281 |
-
{{
|
282 |
-
"status": "insufficient",
|
283 |
-
"reason": "Brief explanation of why (e.g., 'Text is primarily self-introduction', 'Text is too short', etc.)"
|
284 |
-
}}
|
285 |
"""
|
286 |
|
287 |
def process_document_with_quiz(text):
|
|
|
162 |
|
163 |
if is_full_text:
|
164 |
prompt = f"""
|
|
|
|
|
165 |
FIRST ASSESS THE TEXT:
|
166 |
- Check if it's primarily self-introduction, biographical information, or conclusion
|
167 |
- Check if it's too short or lacks meaningful content (less than 100 words of substance)
|
168 |
- If either case is true, respond with a simple JSON: {{"status": "insufficient", "reason": "Brief explanation"}}
|
169 |
+
|
170 |
+
Analyze the following text (likely a transcript or document) and:
|
171 |
|
172 |
+
1. First, do text segmentation and identify DISTINCT key topics within the text
|
|
|
173 |
2. For each segment/topic you identify:
|
174 |
- Provide a SPECIFIC and UNIQUE topic name (3-5 words) that clearly differentiates it from other segments
|
175 |
- List 3-5 key concepts discussed in that segment
|
176 |
- Write a brief summary of that segment (3-5 sentences)
|
177 |
+
- Create 5 quiz questions based DIRECTLY on the content in that segment
|
178 |
|
179 |
For each quiz question:
|
180 |
- Create one correct answer that comes DIRECTLY from the text
|
|
|
187 |
|
188 |
Format your response as JSON with the following structure:
|
189 |
{{
|
|
|
190 |
"segments": [
|
191 |
{{
|
192 |
"topic_name": "Name of segment 1",
|
|
|
216 |
// More segments...
|
217 |
]
|
218 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
"""
|
220 |
else:
|
221 |
prompt = f"""
|
|
|
|
|
222 |
FIRST ASSESS THE TEXT:
|
223 |
- Check if it's primarily self-introduction, biographical information, or conclusion
|
224 |
- Check if it's too short or lacks meaningful content (less than 100 words of substance)
|
225 |
- If either case is true, respond with a simple JSON: {{"status": "insufficient", "reason": "Brief explanation"}}
|
226 |
+
|
227 |
+
Analyze the following text segment and provide:
|
228 |
1. A SPECIFIC and DESCRIPTIVE topic name (3-5 words) that precisely captures the main focus
|
229 |
2. 3-5 key concepts discussed
|
230 |
3. A brief summary (6-7 sentences)
|
231 |
+
4. Create 5 quiz questions based DIRECTLY on the text content (not from your summary)
|
232 |
|
233 |
For each quiz question:
|
234 |
- Create one correct answer that comes DIRECTLY from the text
|
235 |
- Create two plausible but incorrect answers
|
236 |
+
- IMPORTANT and STRICTLY: Ensure all answer options have similar length (± 3 words)
|
237 |
- Ensure the correct answer is clearly indicated
|
238 |
|
239 |
Text segment:
|
|
|
241 |
|
242 |
Format your response as JSON with the following structure:
|
243 |
{{
|
|
|
244 |
"topic_name": "Name of the topic",
|
245 |
"key_concepts": ["concept1", "concept2", "concept3"],
|
246 |
"summary": "Brief summary of the text segment.",
|
|
|
265 |
// More questions...
|
266 |
]
|
267 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
"""
|
269 |
|
270 |
def process_document_with_quiz(text):
|