Spaces:
Sleeping
Sleeping
Update prompts.py
Browse files- prompts.py +41 -216
prompts.py
CHANGED
|
@@ -1,229 +1,54 @@
|
|
| 1 |
-
|
| 2 |
-
Prompt templates for the multi-agent exam generation system
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
# Agent 1 - Generator Prompt (Llama 3.1 70B)
|
| 6 |
-
GENERATOR_PROMPT = """
|
| 7 |
-
You are an expert exam paper generator for engineering education. Create a structured question paper based on the following inputs:
|
| 8 |
-
|
| 9 |
-
SUBJECT: {subject}
|
| 10 |
-
STREAM: {stream}
|
| 11 |
-
SYLLABUS: {syllabus_text}
|
| 12 |
-
REFERENCE CONTEXT: {reference_text}
|
| 13 |
-
REALTIME UPDATES: {realtime_updates}
|
| 14 |
-
|
| 15 |
-
QUESTION DISTRIBUTION:
|
| 16 |
-
- Part A: {part_a_count} questions × 2 marks each
|
| 17 |
-
- Part B: {part_b_count} questions × 13 marks each (Either/Or pattern)
|
| 18 |
-
- Part C: {part_c_count} questions × 14 marks each (Case studies)
|
| 19 |
-
|
| 20 |
-
CRITICAL REQUIREMENTS:
|
| 21 |
-
1. Difficulty Index: Maintain between 1.8-2.5
|
| 22 |
-
2. Unit Distribution: Even coverage across all syllabus units
|
| 23 |
-
3. Bloom's Taxonomy: {bloom_mix}
|
| 24 |
-
4. Tags: {tag_requirements}
|
| 25 |
-
|
| 26 |
-
{stream_specific_template}
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
"questions": [
|
| 38 |
-
{{
|
| 39 |
-
"part": "A",
|
| 40 |
-
"question_no": 1,
|
| 41 |
-
"sub_no": null,
|
| 42 |
-
"marks": 2,
|
| 43 |
-
"unit": 1,
|
| 44 |
-
"bloom_level": "Remember",
|
| 45 |
-
"tags": ["{tag_example}"],
|
| 46 |
-
"course_outcome": "CO1",
|
| 47 |
-
"question_text": "Define key concept from unit 1"
|
| 48 |
-
}},
|
| 49 |
-
{{
|
| 50 |
-
"part": "B",
|
| 51 |
-
"question_no": 1,
|
| 52 |
-
"sub_no": "a",
|
| 53 |
-
"marks": 13,
|
| 54 |
-
"unit": 2,
|
| 55 |
-
"bloom_level": "Apply",
|
| 56 |
-
"tags": ["{tag_example}"],
|
| 57 |
-
"course_outcome": "CO2",
|
| 58 |
-
"question_text": "Explain concept with example OR Solve this problem"
|
| 59 |
-
}},
|
| 60 |
-
{{
|
| 61 |
-
"part": "C",
|
| 62 |
-
"question_no": 1,
|
| 63 |
-
"sub_no": null,
|
| 64 |
-
"marks": 14,
|
| 65 |
-
"unit": 3,
|
| 66 |
-
"bloom_level": "Evaluate",
|
| 67 |
-
"tags": ["Case Study", "{tag_example}"],
|
| 68 |
-
"course_outcome": "CO3",
|
| 69 |
-
"question_text": "Analyze the given case study and provide solutions"
|
| 70 |
-
}}
|
| 71 |
-
]
|
| 72 |
-
}}
|
| 73 |
-
|
| 74 |
-
Generate exactly {total_questions} questions following this structure. Ensure even unit distribution and proper bloom level mixing.
|
| 75 |
"""
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
{
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
1. Bloom's Taxonomy Correctness: {bloom_mix}
|
| 86 |
-
2. Unit Distribution: Even across all syllabus units
|
| 87 |
-
3. Question Count: Part A: {part_a_count}, Part B: {part_b_count}, Part C: {part_c_count}
|
| 88 |
-
4. Tag Completeness: {tag_requirements}
|
| 89 |
-
5. Difficulty Index: Between 1.8-2.5
|
| 90 |
-
6. JSON Validity: Proper structure and formatting
|
| 91 |
-
7. Duplicate Check: No repeated concepts
|
| 92 |
-
8. Ambiguity Check: Clear, unambiguous questions
|
| 93 |
-
|
| 94 |
-
OUTPUT FORMAT:
|
| 95 |
-
{{
|
| 96 |
-
"status": "valid|needs_correction",
|
| 97 |
-
"corrections": [
|
| 98 |
-
{{
|
| 99 |
-
"target": "question_1",
|
| 100 |
-
"issue": "Bloom level incorrect",
|
| 101 |
-
"fix": "Change from 'Remember' to 'Apply'",
|
| 102 |
-
"priority": "high|medium|low"
|
| 103 |
-
}}
|
| 104 |
-
],
|
| 105 |
-
"summary": {{
|
| 106 |
-
"unit_coverage_score": "X/Y units covered",
|
| 107 |
-
"bloom_distribution": {{"Remember": "X%", "Understand": "Y%", ...}},
|
| 108 |
-
"difficulty_estimate": 2.1,
|
| 109 |
-
"overall_quality": "excellent|good|needs_improvement"
|
| 110 |
-
}}
|
| 111 |
-
}}
|
| 112 |
-
|
| 113 |
-
Provide specific, actionable corrections.
|
| 114 |
"""
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
You are the final formatting and output agent. Take the verified content and produce the final structured output.
|
| 119 |
-
|
| 120 |
-
ORIGINAL CONTENT:
|
| 121 |
-
{original_content}
|
| 122 |
|
| 123 |
-
|
| 124 |
-
{corrections}
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
2. Ensure valid JSON structure
|
| 129 |
-
3. Generate three complete blocks:
|
| 130 |
-
- Final Question Paper
|
| 131 |
-
- Answer Key
|
| 132 |
-
- OBE Summary
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
- Model answer
|
| 137 |
-
- Step-by-step solution (where applicable)
|
| 138 |
-
- Marking scheme breakdown
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
- Bloom's taxonomy distribution
|
| 143 |
-
- Difficulty analysis
|
| 144 |
-
- Unit coverage report
|
| 145 |
|
| 146 |
-
|
|
|
|
|
|
|
| 147 |
{{
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
],
|
| 158 |
-
"obe": {{
|
| 159 |
-
"course_outcomes": {{
|
| 160 |
-
"CO1": {{"coverage": "excellent", "questions": ["A1", "B1a"]}},
|
| 161 |
-
"CO2": {{"coverage": "good", "questions": ["A2", "B2a"]}}
|
| 162 |
-
}},
|
| 163 |
-
"bloom_distribution": {{
|
| 164 |
-
"Remember": "30%",
|
| 165 |
-
"Understand": "25%",
|
| 166 |
-
"Apply": "20%",
|
| 167 |
-
"Analyze": "15%",
|
| 168 |
-
"Evaluate": "10%"
|
| 169 |
-
}},
|
| 170 |
-
"difficulty_index": 2.1,
|
| 171 |
-
"unit_coverage": "5/5 units covered",
|
| 172 |
-
"recommendations": "Suggestions for improvement"
|
| 173 |
-
}}
|
| 174 |
}}
|
| 175 |
-
"""
|
| 176 |
-
|
| 177 |
-
# Stream-specific templates
|
| 178 |
-
CSE_TEMPLATE = """
|
| 179 |
-
CSE-SPECIFIC REQUIREMENTS:
|
| 180 |
-
- Company Tags: MAANGO BIG15 (Microsoft, Amazon, Apple, Netflix, Google, Oracle, Bloomberg, IBM, Goldman Sachs, etc.)
|
| 181 |
-
- Focus: Real-world coding problems, system design, algorithms
|
| 182 |
-
- Part B: Either/Or should include coding problems vs theory questions
|
| 183 |
-
- Part C: Case studies from recent tech industry scenarios
|
| 184 |
-
- Bloom's Mix: 60% Remember/Understand, 40% Apply/Analyze/Evaluate
|
| 185 |
-
"""
|
| 186 |
|
| 187 |
-
|
| 188 |
-
NON-CSE SPECIFIC REQUIREMENTS:
|
| 189 |
-
- GATE Reference Tags: All questions must reference GATE patterns
|
| 190 |
-
- Focus: Fundamental concepts, problem-solving, theoretical understanding
|
| 191 |
-
- Part B: Either/Or should include derivation vs application problems
|
| 192 |
-
- Part C: Engineering case studies with real-world applications
|
| 193 |
-
- Bloom's Mix: 50% Remember/Understand, 50% Apply/Analyze/Evaluate
|
| 194 |
"""
|
| 195 |
-
|
| 196 |
-
def get_generator_prompt(subject, stream, syllabus_text, reference_text, realtime_updates,
|
| 197 |
-
part_a_count, part_b_count, part_c_count):
|
| 198 |
-
"""Build the complete generator prompt"""
|
| 199 |
-
|
| 200 |
-
total_marks = (part_a_count * 2) + (part_b_count * 13) + (part_c_count * 14)
|
| 201 |
-
total_questions = part_a_count + (part_b_count * 2) + part_c_count
|
| 202 |
-
|
| 203 |
-
if stream == "CSE":
|
| 204 |
-
stream_template = CSE_TEMPLATE
|
| 205 |
-
bloom_mix = "60% Remember/Understand, 40% Apply/Analyze/Evaluate"
|
| 206 |
-
tag_requirements = "MAANGO BIG15 company tags required"
|
| 207 |
-
tag_example = "Amazon"
|
| 208 |
-
else:
|
| 209 |
-
stream_template = NON_CSE_TEMPLATE
|
| 210 |
-
bloom_mix = "50% Remember/Understand, 50% Apply/Analyze/Evaluate"
|
| 211 |
-
tag_requirements = "GATE reference tags required"
|
| 212 |
-
tag_example = "GATE-2024"
|
| 213 |
-
|
| 214 |
-
return GENERATOR_PROMPT.format(
|
| 215 |
-
subject=subject,
|
| 216 |
-
stream=stream,
|
| 217 |
-
syllabus_text=syllabus_text[:2000], # Limit length
|
| 218 |
-
reference_text=reference_text[:1500],
|
| 219 |
-
realtime_updates=realtime_updates,
|
| 220 |
-
part_a_count=part_a_count,
|
| 221 |
-
part_b_count=part_b_count,
|
| 222 |
-
part_c_count=part_c_count,
|
| 223 |
-
total_marks=total_marks,
|
| 224 |
-
total_questions=total_questions,
|
| 225 |
-
bloom_mix=bloom_mix,
|
| 226 |
-
tag_requirements=tag_requirements,
|
| 227 |
-
stream_specific_template=stream_template,
|
| 228 |
-
tag_example=tag_example
|
| 229 |
-
)
|
|
|
|
| 1 |
+
def build_master_prompt(subject, stream, partA, partB, partC, syllabus, refqp, realtime):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
if stream == "CSE":
|
| 4 |
+
template = """
|
| 5 |
+
You are an expert in CSE academic content creation aligned with MAANGO BIG15.
|
| 6 |
+
Generate:
|
| 7 |
+
- Part A: {partA} × 2 marks
|
| 8 |
+
- Part B: {partB} × 16 marks (Either/Or)
|
| 9 |
+
- Part C: {partC} × 16 marks (Case-based)
|
| 10 |
+
Tag each question:
|
| 11 |
+
(Bloom's Level: <x> | Unit: <n> | Company Tag: <company>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
"""
|
| 13 |
+
else:
|
| 14 |
+
template = """
|
| 15 |
+
You are an expert academic creator for Mechanical/Electrical/Electronics (Non-CSE).
|
| 16 |
+
Generate:
|
| 17 |
+
- Part A: {partA} × 2 marks
|
| 18 |
+
- Part B: {partB} × 13 marks (Either/Or)
|
| 19 |
+
- Part C: {partC} × 14 marks (Case-based)
|
| 20 |
+
Tag each question:
|
| 21 |
+
(Bloom's Level: <x> | Unit: <n> | GATE Reference: <year>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
"""
|
| 23 |
|
| 24 |
+
return f"""
|
| 25 |
+
{template.format(partA=partA, partB=partB, partC=partC)}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
Subject: {subject}
|
|
|
|
| 28 |
|
| 29 |
+
Syllabus:
|
| 30 |
+
{syllabus[:20000]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
Reference QP:
|
| 33 |
+
{refqp[:10000]}
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
Real-time context:
|
| 36 |
+
{realtime}
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
Generate two outputs:
|
| 39 |
+
1. Printable QP
|
| 40 |
+
2. VALID JSON with key "questions", containing list of items:
|
| 41 |
{{
|
| 42 |
+
"part": "A/B/C",
|
| 43 |
+
"question_no": int,
|
| 44 |
+
"sub_no": str or "",
|
| 45 |
+
"marks": int,
|
| 46 |
+
"unit": int,
|
| 47 |
+
"course_outcome": str,
|
| 48 |
+
"bloom_level": str,
|
| 49 |
+
"tags": str,
|
| 50 |
+
"question_text": str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
JSON MUST appear at the bottom of answer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|