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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
OUTPUT FORMAT - MUST BE VALID JSON:
|
| 29 |
+
{{
|
| 30 |
+
"metadata": {{
|
| 31 |
+
"subject": "{subject}",
|
| 32 |
+
"stream": "{stream}",
|
| 33 |
+
"difficulty_index": 2.1,
|
| 34 |
+
"total_marks": {total_marks},
|
| 35 |
+
"units_covered": [1, 2, 3, 4, 5]
|
| 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 |
+
# Agent 2 - Verifier Prompt (Gemma 2 27B)
|
| 78 |
+
VERIFIER_PROMPT = """
|
| 79 |
+
You are a quality verification agent for exam papers. Analyze the generated question paper and identify issues:
|
| 80 |
+
|
| 81 |
+
GENERATED CONTENT:
|
| 82 |
+
{generated_content}
|
| 83 |
+
|
| 84 |
+
VERIFICATION CHECKLIST:
|
| 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 |
+
# Agent 3 - Formatter Prompt (Mixtral-8x7B)
|
| 117 |
+
FORMATTER_PROMPT = """
|
| 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 |
+
VERIFICATION CORRECTIONS:
|
| 124 |
+
{corrections}
|
| 125 |
+
|
| 126 |
+
FINAL OUTPUT REQUIREMENTS:
|
| 127 |
+
1. Apply all corrections from verification
|
| 128 |
+
2. Ensure valid JSON structure
|
| 129 |
+
3. Generate three complete blocks:
|
| 130 |
+
- Final Question Paper
|
| 131 |
+
- Answer Key
|
| 132 |
+
- OBE Summary
|
| 133 |
+
|
| 134 |
+
ANSWER KEY FORMAT:
|
| 135 |
+
For each question, provide:
|
| 136 |
+
- Model answer
|
| 137 |
+
- Step-by-step solution (where applicable)
|
| 138 |
+
- Marking scheme breakdown
|
| 139 |
+
|
| 140 |
+
OBE SUMMARY FORMAT:
|
| 141 |
+
- Course outcome mapping
|
| 142 |
+
- Bloom's taxonomy distribution
|
| 143 |
+
- Difficulty analysis
|
| 144 |
+
- Unit coverage report
|
| 145 |
+
|
| 146 |
+
OUTPUT STRUCTURE:
|
| 147 |
+
{{
|
| 148 |
+
"final_qp": {original_content},
|
| 149 |
+
"answers": [
|
| 150 |
+
{{
|
| 151 |
+
"question_ref": "A1",
|
| 152 |
+
"model_answer": "Detailed answer here...",
|
| 153 |
+
"marking_scheme": ["Point 1: 1 mark", "Point 2: 1 mark"],
|
| 154 |
+
"bloom_level": "Remember",
|
| 155 |
+
"course_outcome": "CO1"
|
| 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 |
+
NON_CSE_TEMPLATE = """
|
| 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 |
+
)
|