Download agents/final_outliners/validator.py from aliroya32/ContiAI: direct link, hf CLI and curl.
- Browser
- Download file 8.61 kB
-
https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/agents/final_outliners/validator.py
- Command line
-
hf download hf://spaces/aliroya32/ContiAI/agents/final_outliners/validator.py
-
curl -L -o validator.py https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/agents/final_outliners/validator.py
8.61 kB
| from crewai import Agent, Task, Crew, Process, LLM | |
| import os | |
| import json | |
| from modules import llm_g | |
| from schemas import ValidatedCurriculumOutput, validated_parser | |
| from functools import cache | |
| def validator_agent(): | |
| model = llm_g() | |
| return Agent( | |
| role="Arabic Educational Validator (Curriculum Quality & Integrity Specialist)", | |
| goal=( | |
| "Ensure that all educational units and subtopics are conceptually complete, logically sequenced, linguistically refined, " | |
| "and pedagogically sound for Arabic learners. Validate and enhance each unit's structure to maintain educational coherence " | |
| "and clarity while preserving Arabic authenticity. Ensure all titles are in Arabic only. and try to include the notes given in the structure." | |
| ), | |
| 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" | |
| " 'General_objectives_of_the_plan': '...',\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" | |
| "}" | |
| ), | |
| # llm=llm_open_c35, | |
| llm=model, | |
| allow_delegation=False, | |
| verbose=True, | |
| reasoning=True, | |
| max_iter=100, | |
| cache=False, | |
| ) | |
| def validation_task(validator_agent): | |
| return Task( | |
| description=( | |
| "Validate, refine, and enhance all generated educational units and their subtopics (only those needing improvement). " | |
| "Ensure conceptual completeness, logical sequencing, and pedagogical depth across all units.\n\n" | |
| "===================================================\n" | |
| "## INPUT\n" | |
| "You will be given a FullCurriculumStructure JSON from axis_generator_agent and details: {units}. " | |
| "NOTES may also be provided {note}. These notes contain additional instructions or required new content. " | |
| "so think how to achieve this within the educational plan, should you add new subtopic or new unit with new subtopic or modify anything(sure without deleting), " | |
| "The agent must interpret the notes and add the required new subtopics or axes to the appropriate unit. " | |
| "Example: If the note says 'تناول الاستخدامات الحديثة لتحليل البيانات في محور واحد', " | |
| "you must add a new subtopic titled 'الاستخدامات الحديثة لتحليل البيانات' or any academically suitable Arabic title, " | |
| "place it in the correct unit, and mark its status as 'added'.\n\n" | |
| "===================================================\n" | |
| "PRIMARY OBJECTIVE\n" | |
| "===================================================\n" | |
| "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" | |
| "5- Ensure the unit name best expresses its content in professional Arabic.\n" | |
| "6- Avoid punctuation marks (– , ; : . ! ? , /) except for simple questions.\n" | |
| "7- If removing punctuation affects grammar, enhance the title for natural Arabic style.\n\n" | |
| "===================================================\n" | |
| "PHASE 1 — COMPREHENSIVENESS & DEPTH ANALYSIS\n" | |
| "===================================================\n" | |
| "1. Analyze all subtopics for each unit and unit details.\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 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 and all details is represented.\n" | |
| "2. Ensure 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" | |
| "===================================================\n" | |
| "4. Validate that each Subtopic:\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" | |
| " - Title length: concise (4–8 words preferred).\n" | |
| " - Clear and contextually linked to its unit.\n" | |
| " - Tone appropriate for {audience}.\n" | |
| " - Avoids punctuation marks except for simple questions.\n" | |
| " - Represents one coherent idea, not compound.\n" | |
| " - Avoids activity-based terms like 'ورشة عمل' or 'نشاط'.\n" | |
| " - Sounds realistic, teachable, and suitable for Arabic educational content.\n\n" | |
| "===================================================\n" | |
| "PHASE 4.1 — ARABIC LANGUAGE INTEGRITY ENFORCEMENT\n" | |
| "===================================================\n" | |
| "1. Ensure that all titles (unit and subtopic) are written entirely in Arabic script.\n" | |
| "2. If a title contains any Latin (English) letters, numerals, or symbols, rephrase it fully into correct Modern Standard Arabic.\n" | |
| "3. Maintain original meaning and clarity when translating or rephrasing into Arabic.\n" | |
| "4. Titles must not contain any transliterations (e.g., 'Entrepreneurship', 'AI', 'Design Thinking'). Replace them with Arabic equivalents.\n" | |
| "5. Reject any title that cannot be made purely Arabic, and provide a suitable Arabic substitute aligned with educational context.\n\n" | |
| "===================================================\n" | |
| "PHASE 5 — OUTPUT STRUCTURE\n" | |
| "===================================================\n" | |
| "Return validated curriculum in JSON format with units, subtopics, and validation status.\n\n" | |
| "===================================================\n" | |
| "## NOTES\n" | |
| "- Keep phrasing in professional Modern Standard Arabic.\n" | |
| "- Avoid dual, poetic, or abstract titles.\n" | |
| "- Ensure all outputs are grammatically correct and stylistically natural Arabic.\n" | |
| "- Titles must not include any English or foreign words." | |
| "- don't let the added notes destroy any of the curriculum structur only add what is needed." | |
| ), | |
| # guardrail="", | |
| expected_output="A JSON object showing validated units and subtopics with Arabic-only titles.", | |
| output_json=ValidatedCurriculumOutput, | |
| output_parser=validated_parser, | |
| agent=validator_agent, | |
| ) | |