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,
)