ziadsameh32's picture
final-version
17d0f30
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,
)