Spaces:
Sleeping
Sleeping
File size: 13,916 Bytes
f4d903c 522b289 17d0f30 f4d903c dc95ab6 f4d903c dc95ab6 f4d903c dc95ab6 f4d903c dc95ab6 f4d903c dc95ab6 f4d903c dc95ab6 522b289 f4d903c dc95ab6 f4d903c dc95ab6 f4d903c dc95ab6 f4d903c 17d0f30 f4d903c 17d0f30 f4d903c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | from crewai import Agent, Task, Crew, Process, LLM
import os
import json
from modules import llm_5m
from schemas import ValidatedCurriculumOutput
validator_agent = Agent(
role="Arabic Educational Validator (Curriculum Quality & Integrity Specialist)",
goal=(
"Validate, refine, and enhance all generated educational units and their axes (subtopics). "
"Ensure conceptual completeness, logical sequencing, and pedagogical depth across all units.\n\n"
"===================================================\n"
"๐ฏ PRIMARY OBJECTIVE\n"
"===================================================\n"
"Your mission is to **validate, refine, and enhance** all educational units and subtopics (axes). "
"Ensure each unit exhibits:\n"
"1๏ธโฃ Full conceptual and pedagogical integration.\n"
"2๏ธโฃ Logical sequencing of ideas.\n"
"3๏ธโฃ Arabic educational clarity and realism.\n"
"4๏ธโฃ Comprehensive coverage of all described relations, aspects, and intentions.\n\n"
"===================================================\n"
"๐ง PHASE 1 โ COMPREHENSIVENESS & DEPTH ANALYSIS\n"
"===================================================\n"
"1. Analyze all subtopics for each unit.\n"
"2. Identify missing conceptual foundations (definitions, context, prerequisites, motivation).\n"
"3. Add any necessary **introductory subtopics** with clear Arabic titles and purposes.\n"
"4. Detect and remove any redundant or overlapping axes.\n\n"
"===================================================\n"
"๐ PHASE 2 โ INTEGRATION & SEQUENCING VALIDATION\n"
"===================================================\n"
"1. Ensure a smooth conceptual progression from basic to advanced.\n"
"2. Merge or rephrase redundant axes while preserving educational intent.\n"
"3. Add **bridging subtopics** if conceptual jumps exist.\n"
"4. Reorder axes if needed to restore logical flow.\n\n"
"===================================================\n"
"๐ PHASE 3 โ REALISM & COVERAGE VALIDATION\n"
"===================================================\n"
"1. Confirm every conceptual aspect in the unitโs focus is represented.\n"
"2. Ensure all subtopics are realistic and pedagogically valid for the target audience.\n"
"3. Add missing real-world or practical dimensions.\n"
"4. Maintain natural, professional Arabic phrasing.\n\n"
"===================================================\n"
"๐ PHASE 4 โ SUBTOPICS TITLE QUALITY & LANGUAGE VALIDATION"
"===================================================\n"
## ADD
"4. Validate that each axis:\n"
" - Aligns with Arabic educational title standards (clarity, focus, precision, and appropriateness).\n"
" - Avoids dual titles, poetic phrasing, or abstract metaphors.\n\n"
"5. ๐ **Subtopics Title Quality & Language Validation**\n"
" - Each subtopic title is the learnerโs first point of contact with the concept, so ensure the following:\n"
" โ
Title length: concise (4โ8 words preferred).\n"
" โ
Clear and contextually linked to its unit or topic.\n"
" โ
Written in tone appropriate for {audience}.\n"
" โ
Avoids punctuation marks (โ , ; : . ! ? , /) except for simple questions.\n"
" โ
Represents one coherent idea โ avoid compound or dual phrasing.\n"
" โ
Avoids activity-based terms like 'ูุฑุดุฉ ุนู
ู' or 'ูุดุงุท'.\n"
" โ
Sounds realistic, teachable, and suitable for Arabic educational content.\n\n"
"===================================================\n"
"๐งพ PHASE 5 โ OUTPUT STRUCTURE\n"
"===================================================\n"
"For each unit, return its improved axes, indicating for every axis whether it was:\n"
"โข 'status': 'kept' (unchanged), 'rephrased' (edited), 'added' (new), or 'removed' (deleted/merged).\n\n"
),
backstory=(
"You are a senior Arabic educational content validator and curriculum refinement expert. "
"You specialize in verifying conceptual completeness, depth, and sequencing of educational materials. "
"You understand Bloomโs taxonomy and Arabic pedagogical standards deeply. "
"You ensure all subtopics form a coherent, realistic, and progressive learning journey for the audience. "
"You maintain academic rigor and cultural authenticity while improving clarity and depth."
),
output_format=(
"Return a valid JSON with the following structure:\n"
"{\n"
" 'main_concept': '...',\n"
" 'related_concepts': ['...', '...'],\n"
" 'validated_units': [\n"
" {\n"
" 'unit_number': 1,\n"
" 'title': '...',\n"
" 'focus': '...',\n"
" 'validated_axes': [\n"
" {\n"
" 'axis_number': 1,\n"
" 'original_title': '...',\n"
" 'validated_title': '...',\n"
" 'original_purpose': '...',\n"
" 'validated_purpose': '...',\n"
" 'status': 'kept' | 'rephrased' | 'added' | 'removed'\n"
" }\n"
" ]\n"
" }\n"
" ]\n"
"}"
),
examples=[
{
"input": {
"main_concept": "ุงูุชูููุฑ ุงูุชุตู
ูู
ู",
"related_concepts": ["ุญู ุงูู
ุดููุงุช", "ุงูุฅุจุฏุงุน", "ุงุชุฎุงุฐ ุงููุฑุงุฑ"],
"units": [
{
"unit_number": 3,
"title": "ุงููุญุฏุฉ ุงูุซุงูุซุฉ: ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูุญู ุงูู
ุดููุงุช",
"focus": "ุชูุธูู ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูู
ููุฌ ูุนุงู ูู ู
ุนุงูุฌุฉ ุงูุชุญุฏูุงุช ูุฅูุฌุงุฏ ุญููู ู
ุจุชูุฑุฉ",
"axes": [
{
"axis_number": 1,
"title": "ู
ุงุฐุง ูุนูู ุญู ุงูู
ุดููุฉุ",
"purpose": "ุชูุถูุญ ุงูู
ูููู
ุงููุธุฑู ูุญู ุงูู
ุดููุงุช",
},
{
"axis_number": 2,
"title": "ุฃุฑุจุน ุฎุทูุงุช ูุญู ุงูู
ุดููุฉ",
"purpose": "ุดุฑุญ ุงูุฎุทูุงุช ุงูุฃุณุงุณูุฉ",
},
{
"axis_number": 3,
"title": "ุงููุฑู ุจูู ุงูุชูููุฑ ุงูุชุญูููู ูุงูุชุตู
ูู
ู",
"purpose": "ุงูู
ูุงุฑูุฉ ุจูู ุงูููุฌูู",
},
{
"axis_number": 4,
"title": "ููุฌ ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูุญู ุงูู
ุดููุงุช",
"purpose": "ุดุฑุญ ููููุฉ ุชุทุจูู ุงูุชูููุฑ ุงูุชุตู
ูู
ู",
},
{
"axis_number": 5,
"title": "ูู
ุงุฐุฌ ุชุทุจูููุฉ ูุงุฌุญุฉ",
"purpose": "ุนุฑุถ ุฃู
ุซูุฉ ุนู
ููุฉ",
},
],
}
],
},
"output": {
"validated_units": [
{
"unit_number": 3,
"title": "ุงููุญุฏุฉ ุงูุซุงูุซุฉ: ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูุญู ุงูู
ุดููุงุช",
"focus": "ุชูุธูู ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูู
ููุฌ ูุนุงู ูู ู
ุนุงูุฌุฉ ุงูุชุญุฏูุงุช ูุฅูุฌุงุฏ ุญููู ู
ุจุชูุฑุฉ",
"validated_axes": [
{
"axis_number": 1,
"original_title": "ู
ุงุฐุง ูุนูู ุญู ุงูู
ุดููุฉุ",
"validated_title": "ู
ุง ุงูู
ูุตูุฏ ุจุญู ุงูู
ุดููุฉุ",
"original_purpose": "ุชูุถูุญ ุงูู
ูููู
ุงููุธุฑู ูุญู ุงูู
ุดููุงุช",
"validated_purpose": "ุชุนุฑูู ู
ูููู
ุญู ุงูู
ุดููุฉ ูุฃูู
ูุชู ูู ุงูุณูุงู ุงูุนู
ูู",
"status": "rephrased",
},
{
"axis_number": 2,
"original_title": "ุฃุฑุจุน ุฎุทูุงุช ูุญู ุงูู
ุดููุฉ",
"validated_title": "ุฎุทูุงุช ุญู ุงูู
ุดููุฉ",
"original_purpose": "ุดุฑุญ ุงูุฎุทูุงุช ุงูุฃุณุงุณูุฉ",
"validated_purpose": "ุชุจุณูุท ุงูู
ุฑุงุญู ุงูุฃุณุงุณูุฉ ูุญู ุงูู
ุดููุงุช ุจุฃุณููุจ ุชุนููู
ู",
"status": "rephrased",
},
{
"axis_number": 3,
"original_title": "ุงููุฑู ุจูู ุงูุชูููุฑ ุงูุชุญูููู ูุงูุชุตู
ูู
ู",
"validated_title": "ุงููุฑู ุจูู ุงูุชูููุฑ ุงูุชุญูููู ูุงูุชุตู
ูู
ู ูู ุญู ุงูู
ุดููุงุช",
"original_purpose": "ุงูู
ูุงุฑูุฉ ุจูู ุงูููุฌูู",
"validated_purpose": "ุฅุจุฑุงุฒ ุงููุฑูู ุงูุฌููุฑูุฉ ุจูู ุงูุฃุณููุจูู ูู ู
ุนุงูุฌุฉ ุงูุชุญุฏูุงุช",
"status": "rephrased",
},
{
"axis_number": 4,
"original_title": "ููุฌ ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูุญู ุงูู
ุดููุงุช",
"validated_title": "ุชุทุจูู ููุฌ ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูู ุญู ุงูู
ุดููุงุช",
"original_purpose": "ุดุฑุญ ููููุฉ ุชุทุจูู ุงูุชูููุฑ ุงูุชุตู
ูู
ู",
"validated_purpose": "ุดุฑุญ ู
ููุฌู ูููููุฉ ุงุณุชุฎุฏุงู
ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูุฅูุชุงุฌ ุญููู ู
ุจุชูุฑุฉ",
"status": "rephrased",
},
{
"axis_number": 5,
"original_title": "ูู
ุงุฐุฌ ุชุทุจูููุฉ ูุงุฌุญุฉ",
"validated_title": "ูู
ุงุฐุฌ ุชุทุจูููุฉ ูุงุฌุญุฉ ูู ุญู ุงูู
ุดููุงุช ุจุงูุชูููุฑ ุงูุชุตู
ูู
ู",
"original_purpose": "ุนุฑุถ ุฃู
ุซูุฉ ุนู
ููุฉ",
"validated_purpose": "ุนุฑุถ ุฏุฑุงุณุงุช ุญุงูุฉ ุชุจูู ูุฌุงุญ ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูู ู
ูุงูู ูุงูุนูุฉ",
"status": "rephrased",
},
{
"axis_number": 6,
"original_title": None,
"validated_title": "ู
ูุฏู
ุฉ ูู ุงูุชูููุฑ ุงูุชุตู
ูู
ู ูุญู ุงูู
ุดููุงุช",
"original_purpose": None,
"validated_purpose": "ุชูุฏูู
ุฎูููุฉ ุชุนุฑูููุฉ ุชู
ููุฏ ูููู
ุจููุฉ ุงูู
ุญุงูุฑ",
"status": "added",
},
],
}
]
},
}
],
# llm=llm_open_c35,
llm=llm_5m,
allow_delegation=False,
verbose=True,
reasoning=True,
max_iter=100,
)
validation_task = Task(
description=(
"## GOAL\n"
"Validate and enhance the quality of generated educational units and their subtopics (axes). "
"Ensure conceptual completeness, logical sequencing, realism, and Arabic educational clarity.\n\n"
"## INPUT\n"
"You are provided with a FullCurriculumStructure JSON output from the axis_generator_agent.\n\n"
"## PROCESS\n"
"1๏ธโฃ Analyze each unit and its axes for completeness and depth.\n"
"2๏ธโฃ Identify missing conceptual or prerequisite subtopics and add them.\n"
"3๏ธโฃ Reorder or merge axes to ensure logical progression.\n"
"4๏ธโฃ Rephrase any unclear or non-educational titles.\n"
"5๏ธโฃ Validate the linguistic and stylistic quality of all subtopic titles "
"(clarity, focus, precision, and appropriateness for the audience).\n"
"6๏ธโฃ Mark each axis with a 'status' showing if it was kept, rephrased, added, or removed.\n\n"
"## OUTPUT\n"
"Return the improved curriculum structure in valid JSON format showing validation results.\n\n"
"## NOTES\n"
"- Keep phrasing in professional, natural Arabic.\n"
"- Maintain 5โ7 axes per unit after validation.\n"
"- Avoid dual, poetic, or abstract titles.\n"
"- Ensure titles are concise (4โ8 words), contextually clear, and free from unnecessary punctuation.\n"
"- Do not lose any important concept; prefer rephrasing over deletion.\n"
),
expected_output="A JSON object showing validated units and axes.",
agent=validator_agent,
output_json=ValidatedCurriculumOutput,
)
|