from crewai import Agent, Task, Crew, Process, LLM import os import json from modules import llm from schemas import CurriculumOutline # --------------------------- # === Agent 3: Module Organizer === # --------------------------- def designer_agent(): model = llm() return Agent( role="Module Organizer Agent (Group into 4 modules)", goal=( "استلم الـ20 محورًا من Agent2. نظّمهم إلى **4 وحدات**، كل وحدة تحتوي على **5 مواضيع** " "مرتبة متسلسلة ومنطقية. أعطِ كل وحدة عنوانًا واضحًا ومعبّرًا (module_title بالعربية)، " "وقصّر عناوين المواضيع بحيث تكون جاهزة للاستخدام في الـ Curriculum (كل موضوع عبارة " "عن جملة قصيرة أو عبارة). أعد صياغة المواضيع إن لزم لتكون متجانسة معًا." ), backstory=( "أنت كبير مصممي مناهج. مهمتك إخراج المخرجات بصيغة CurriculumOutline المتوافقة مع الـ schema." ), llm=model, allow_delegation=False, verbose=True, ) def design_task(designer_agent): return Task( description="تنظيم المحاور العشرين إلى 4 وحدات × 5 مواضيع في كل وحدة.", expected_output=( "A valid JSON object with this structure:\n" "{\n" ' "title": "string (Arabic curriculum title)",\n' ' "units": [\n' " {\n" ' "unit_title": "string (Arabic, must reflect the title)",\n' ' "topics": ["topic1", "topic2", "topic3", "topic4", "topic5"]\n' " }, ... (4 units total)\n" " ]\n" "}\n" "The output must be valid JSON, without markdown formatting or code blocks." ), output_json=CurriculumOutline, # output_file=os.path.join(output_dir, "curriculum_outline.json"), agent=designer_agent, )