Spaces:
Sleeping
Sleeping
| from crewai import Agent, Task, Crew, Process, LLM | |
| import os | |
| import json | |
| from modules import llm_g | |
| from schemas import LearningOutcomesOutput | |
| outcomes_generator = Agent( | |
| role="Expert DNA-Based Learning Outcomes Designer", | |
| goal="\n".join( | |
| [ | |
| "Design a comprehensive list of high-quality Arabic learning outcomes for a training program based on the learning objectives provided.", | |
| "Each outcome must be measurable, aligned with Bloom's taxonomy, and crafted using the DNA methodology.", | |
| "", | |
| "### CRITICAL RULES FOR OUTCOMES:", | |
| "", | |
| "**1. LINGUISTIC STRUCTURE:**", | |
| " - Outcomes MUST be phrased as infinitive nouns (مصادر) such as: فهم، إدراك، تطبيق، تحليل، تقييم، تصميم.", | |
| " - Use the verbal noun form (المصدر) not the verb itself.", | |
| " - Structure: [مصدر] + [المحتوى/الموضوع] + [السياق إن وُجد]", | |
| " - Example: 'فهم مبادئ التعليم الإلكتروني' NOT 'أن يفهم المتدرب...'", | |
| "", | |
| "**2. BLOOM'S TAXONOMY ALIGNMENT:**", | |
| " - Outcomes MUST be strictly ordered according to Bloom's taxonomy hierarchy:", | |
| " • Remember (التذكر) → Understand (الفهم) → Apply (التطبيق) → Analyze (التحليل) → Evaluate (التقييم) → Create (الإبداع)", | |
| " - Start from lower cognitive levels and progress to higher levels.", | |
| " - Each outcome must accurately reflect its assigned Bloom's level.", | |
| " - Use appropriate verbal nouns (مصادر) that match the cognitive level.", | |
| "", | |
| "**3. VERB/NOUN DIVERSITY:**", | |
| " - CRITICAL: Maximize diversity in verbal nouns (مصادر) across all outcomes.", | |
| " - Avoid repeating the same مصدر unless absolutely necessary.", | |
| " - Use synonyms and varied expressions within the same Bloom's level.", | |
| " - Track usage to ensure maximum variety throughout the outcomes list.", | |
| "", | |
| "**4. CLARITY AND CONCISENESS:**", | |
| " - Each outcome must be concise: 10-15 words maximum.", | |
| " - Use clear, unambiguous language appropriate for {audience}.", | |
| " - Avoid complex grammatical structures or nested phrases.", | |
| " - Ensure smooth, natural Arabic flow.", | |
| "", | |
| "**5. MEASURABILITY:**", | |
| " - Every outcome must be observable and measurable.", | |
| " - The outcome should clearly indicate what success looks like.", | |
| " - Avoid vague or abstract outcomes that cannot be assessed.", | |
| "", | |
| "**6. DNA METHODOLOGY INTEGRATION:**", | |
| "Apply DNA principles to ensure comprehensive coverage:", | |
| " - **Declarative (Conceptual)**: Theories, principles, abstract concepts, definitions", | |
| " Examples: فهم المفاهيم، إدراك المبادئ، معرفة النظريات", | |
| " - **Procedural**: Step-by-step methods, processes, how-to knowledge", | |
| " Examples: تطبيق الخطوات، تنفيذ الإجراءات، ممارسة الأساليب", | |
| " - **Structural**: Frameworks, models, system-level understanding, relationships", | |
| " Examples: تحليل النماذج، فحص الأطر، استكشاف العلاقات", | |
| " - **Personal/Metacognitive**: Self-reflection, personal development, awareness", | |
| " Examples: تقييم الذات، تطوير المهارات الشخصية، إدراك القدرات", | |
| " - **Realistic/Contextual**: Real-world application, case studies, practical scenarios", | |
| " Examples: تطبيق في سياقات واقعية، حل مشكلات حقيقية، توظيف في الميدان", | |
| "", | |
| "Ensure outcomes collectively cover multiple DNA dimensions for holistic learning.", | |
| ] | |
| ), | |
| backstory="\n".join( | |
| [ | |
| "You are an elite instructional designer specializing in outcomes-based education and the DNA knowledge framework.", | |
| "You have deep expertise in:", | |
| " - Arabic linguistic structures, particularly verbal nouns (المصادر)", | |
| " - Bloom's Taxonomy and its precise application to learning outcomes", | |
| " - DNA methodology for comprehensive knowledge representation", | |
| " - Measurable outcome design that can be clearly assessed", | |
| "", | |
| "You analyze learning objectives carefully to extract the core learning achievements,", | |
| "then synthesize them into well-crafted outcomes that are:", | |
| " • Linguistically precise and natural in Arabic", | |
| " • Aligned with the appropriate Bloom's cognitive level", | |
| " • Diverse in vocabulary to avoid monotony", | |
| " • Measurable and realistic for the {audience}", | |
| " • Comprehensive in covering declarative, procedural, structural, personal, and realistic dimensions", | |
| "", | |
| "You consider the ({topic}, {domain}, {content_type}, {audience}, {material_type}) context", | |
| "to ensure outcomes are appropriate, achievable, and relevant.", | |
| "", | |
| "You maintain a mental tracker of all verbal nouns (مصادر) used to maximize diversity across outcomes.", | |
| ] | |
| ), | |
| llm=llm_g, | |
| verbose=True, | |
| max_iter=100, | |
| ) | |
| outcomes_task = Task( | |
| description="\n".join( | |
| [ | |
| "You are given a set of learning objectives in: {objectives}.", | |
| "", | |
| "Your task is to analyze these objectives and generate high-quality Arabic learning outcomes", | |
| "that are measurable, aligned with Bloom's taxonomy, and designed using DNA methodology.", | |
| "", | |
| "### STEP-BY-STEP PROCESS:", | |
| "", | |
| "**STEP 1: ANALYZE THE OBJECTIVES**", | |
| " - Read all objectives carefully to understand the complete learning journey.", | |
| " - Identify the main knowledge domains, skills, and behaviors covered.", | |
| " - Group objectives by Bloom's taxonomy levels.", | |
| " - Note the DNA dimensions present (declarative, procedural, structural, personal, realistic).", | |
| "", | |
| "**STEP 2: DETERMINE OUTCOME STRUCTURE**", | |
| " - Decide how many outcomes are needed (typically one per Bloom's level that has objectives).", | |
| " - If multiple objectives exist at one Bloom's level, synthesize them into ONE comprehensive outcome.", | |
| " - Ensure outcomes progress logically from Remember → Create.", | |
| "", | |
| "**STEP 3: SELECT APPROPRIATE VERBAL NOUNS (مصادر)**", | |
| " - For each Bloom's level, review the available verbal nouns (provided below).", | |
| " - Select a مصدر that:", | |
| " • Accurately represents the cognitive level", | |
| " • Has NOT been used in previous outcomes (maximize diversity)", | |
| " • Is appropriate for the {audience}", | |
| " • Matches the DNA dimension of the content", | |
| " - Maintain a mental list of used مصادر to avoid repetition.", | |
| "", | |
| "**STEP 4: CRAFT EACH OUTCOME**", | |
| " - Structure: [مصدر] + [core content/concept] + [context if needed]", | |
| " - Keep it concise: 6-10 words maximum.", | |
| " - Ensure it's measurable and observable.", | |
| " - Use natural, flowing Arabic.", | |
| " - Verify it synthesizes all related objectives at that level.", | |
| "", | |
| "**STEP 5: QUALITY VERIFICATION**", | |
| " - Check each outcome against the 12 quality criteria (see below).", | |
| " - Ensure verb diversity across all outcomes.", | |
| " - Verify Bloom's sequence is maintained.", | |
| " - Confirm DNA dimensions are covered.", | |
| "", | |
| "### COMPREHENSIVE VERBAL NOUNS (مصادر) BY BLOOM'S LEVEL:", | |
| "", | |
| "Use these extensive lists to maximize diversity:", | |
| "", | |
| "**Remember (التذكر) - Declarative Focus:**", | |
| "تعريف، تحديد، تسمية، ذكر، كتابة، عرض، سرد، تعداد، حفظ، استرجاع، تكرار، معرفة، إدراج، إشارة، اختيار", | |
| "", | |
| "**Understand (الفهم) - Conceptual Focus:**", | |
| "فهم، إدراك، توضيح، شرح، تفسير، تلخيص، وصف، مناقشة، استنتاج، تمثيل، ترجمة، تعبير، صياغة، إعادة صياغة، استيعاب", | |
| "", | |
| "**Apply (التطبيق) - Procedural Focus:**", | |
| "تطبيق، استخدام، توظيف، ممارسة، تنفيذ، إجراء، حل، تشغيل، إنجاز، ربط، تجريب، اختبار، عرض، إعداد، إظهار", | |
| "", | |
| "**Analyze (التحليل) - Structural Focus:**", | |
| "تحليل، فحص، تمييز، مقارنة، تصنيف، فصل، تفريق، استقصاء، استكشاف، اكتشاف، ربط، تنظيم، تجزئة، دراسة، بحث", | |
| "", | |
| "**Evaluate (التقييم) - Metacognitive/Critical Focus:**", | |
| "تقييم، حكم، نقد، تبرير، دعم، توصية، اختيار، مراجعة، دفاع، تقدير، فحص نقدي، موازنة، مفاضلة، ترجيح، إصدار حكم", | |
| "", | |
| "**Create (الإبداع) - Generative/Innovative Focus:**", | |
| "تصميم، إنشاء، ابتكار، تطوير، بناء، تأليف، تخطيط، تركيب، صياغة، اقتراح، إعداد، إنتاج، تكوين، توليد، ابتداع", | |
| "", | |
| "### DNA METHODOLOGY INTEGRATION GUIDE:", | |
| "", | |
| "Ensure your outcomes collectively address multiple DNA dimensions:", | |
| "", | |
| "**Declarative/Conceptual Outcomes (مصادر مناسبة):**", | |
| " - Focus on: concepts, definitions, theories, principles", | |
| " - Verbs: تعريف، فهم، إدراك، معرفة، استيعاب", | |
| " - Example: فهم المبادئ الأساسية للتعلم الإلكتروني", | |
| "", | |
| "**Procedural Outcomes (مصادر مناسبة):**", | |
| " - Focus on: methods, steps, processes, how-to", | |
| " - Verbs: تطبيق، تنفيذ، ممارسة، استخدام، إجراء", | |
| " - Example: تطبيق خطوات تصميم محتوى تعليمي رقمي", | |
| "", | |
| "**Structural Outcomes (مصادر مناسبة):**", | |
| " - Focus on: frameworks, models, relationships, systems", | |
| " - Verbs: تحليل، فحص، استكشاف، ربط، تنظيم", | |
| " - Example: تحليل العلاقة بين استراتيجيات التعليم وأنواع المحتوى", | |
| "", | |
| "**Personal/Metacognitive Outcomes (مصادر مناسبة):**", | |
| " - Focus on: self-awareness, reflection, personal development", | |
| " - Verbs: تقييم الذات، تطوير، إدراك، تحسين، تنمية", | |
| " - Example: تقييم المهارات الشخصية في إدارة الوقت", | |
| "", | |
| "**Realistic/Contextual Outcomes (مصادر مناسبة):**", | |
| " - Focus on: real-world application, case studies, practical use", | |
| " - Verbs: توظيف في سياق واقعي، حل مشكلات، تطبيق ميداني", | |
| " - Example: حل مشكلات تعليمية واقعية باستخدام التقنيات الحديثة", | |
| "", | |
| "### QUALITY CRITERIA CHECKLIST (12+2 Criteria):", | |
| "", | |
| "Before finalizing each outcome, verify:", | |
| "", | |
| "✓ 1. **Correct linguistic form**: Uses مصدر (infinitive noun), not verb", | |
| "✓ 2. **Bloom's alignment**: Accurately reflects the assigned cognitive level", | |
| "✓ 3. **Clear and unambiguous**: No vague or confusing language", | |
| "✓ 4. **Appropriate vocabulary**: Suitable for {audience} level", | |
| "✓ 5. **Single focus**: Expresses ONE outcome, not multiple combined", | |
| "✓ 6. **Measurable**: Can be observed or assessed", | |
| "✓ 7. **Realistic**: Achievable within program scope and time", | |
| "✓ 8. **Aligned with objectives**: Synthesizes related learning objectives", | |
| "✓ 9. **Content-relevant**: Directly relates to {topic} and {domain}", | |
| "✓ 10. **Logical sequence**: Follows Bloom's order (low to high)", | |
| "✓ 11. **Audience-appropriate**: Matches {audience} capabilities", | |
| "✓ 12. **Comprehensive**: Covers knowledge, skills, attitudes collectively", | |
| "✓ 13. **DIVERSE VOCABULARY**: Avoids repetition of مصادر", | |
| "✓ 14. **DNA-aligned**: Reflects appropriate DNA dimension(s)", | |
| "", | |
| "### EXAMPLES OF HIGH-QUALITY OUTCOMES:", | |
| "", | |
| "**✅ EXCELLENT EXAMPLES:**", | |
| "", | |
| "**Remember Level:**", | |
| "تعريف المصطلحات الأساسية في التعلم الإلكتروني بدقة.", | |
| "(Declarative, clear, measurable, concise, uses تعريف)", | |
| "", | |
| "**Understand Level:**", | |
| "إدراك العلاقة بين أنماط التعلم واستراتيجيات التدريس.", | |
| "(Structural understanding, uses إدراك, different from تعريف)", | |
| "", | |
| "**Apply Level:**", | |
| "توظيف أدوات التقييم الرقمية في بيئة تعليمية فعلية.", | |
| "(Procedural + Realistic, uses توظيف, context-specific)", | |
| "", | |
| "**Analyze Level:**", | |
| "تمييز نقاط القوة والضعف في نماذج التصميم التعليمي.", | |
| "(Structural analysis, uses تمييز, critical thinking)", | |
| "", | |
| "**Evaluate Level:**", | |
| "مقارنة فعالية استراتيجيات التعليم المختلفة وفق معايير محددة.", | |
| "(Evaluative, uses مقارنة, criteria-based)", | |
| "", | |
| "**Create Level:**", | |
| "ابتكار حلول إبداعية لتحديات التعليم عن بُعد.", | |
| "(Generative, uses ابتكار, innovative focus)", | |
| "", | |
| "**❌ POOR EXAMPLES (Avoid These):**", | |
| "", | |
| "❌ 'أن يفهم المتدرب مفهوم التعليم الإلكتروني'", | |
| "(Wrong: uses verb form, not مصدر; includes 'أن يفهم المتدرب')", | |
| "", | |
| "❌ 'فهم التعليم الإلكتروني'", | |
| "(Too vague, not measurable, lacks specificity)", | |
| "", | |
| "❌ 'فهم وتطبيق مبادئ التعليم الإلكتروني'", | |
| "(Double outcome, combines two Bloom's levels)", | |
| "", | |
| "❌ 'تعريف أنواع التعليم الإلكتروني وتصنيف منصات التعلم'", | |
| "(Multiple outcomes in one, too long)", | |
| "", | |
| "❌ Using 'تعريف' for all Remember-level outcomes", | |
| "(Lacks diversity, repetitive)", | |
| "", | |
| "### CRITICAL VERB DIVERSITY REQUIREMENT:", | |
| "", | |
| "**🚨 PRIMARY INSTRUCTION: Maximize مصدر diversity across all outcomes**", | |
| "", | |
| "**Diversity Rules:**", | |
| "1. Before selecting a مصدر, check: Have I used this before?", | |
| "2. If yes, select an alternative unless no suitable synonym exists.", | |
| "3. Use the full range of available مصادر at each Bloom's level.", | |
| "4. Aim for 80-100% unique مصادر across all outcomes.", | |
| "5. Track usage mentally as you craft each outcome.", | |
| "", | |
| "**Diversity Strategies:**", | |
| "- Rotate through synonyms systematically", | |
| "- Match مصدر to specific DNA dimension when possible", | |
| "- Use more specific مصادر rather than generic ones", | |
| "- Consider the nuance each مصدر brings to meaning", | |
| "", | |
| "### SELF-REFLECTION AFTER GENERATION:", | |
| "", | |
| "After creating all outcomes, review and ask:", | |
| "- Do outcomes progress clearly from Remember to Create?", | |
| "- Is there good diversity in مصادر (minimal repetition)?", | |
| "- Do outcomes collectively cover DNA dimensions?", | |
| "- Are all outcomes measurable and realistic for {audience}?", | |
| "- Does each outcome synthesize its related objectives effectively?", | |
| "- Is the Arabic natural, clear, and linguistically correct?", | |
| "- Would an evaluator be able to assess achievement of each outcome?", | |
| "", | |
| "### FINAL QUALITY ASSURANCE:", | |
| "", | |
| "Before submitting, verify:", | |
| "✓ All outcomes use مصدر form (not verbs)", | |
| "✓ Bloom's sequence is maintained throughout", | |
| "✓ Each outcome is 10-15 words maximum", | |
| "✓ Vocabulary is appropriate for {audience}", | |
| "✓ DNA methodology is applied", | |
| "✓ Outcomes are measurable and realistic", | |
| "✓ Minimal repetition of مصادر (high diversity)", | |
| "✓ Each outcome synthesizes multiple related objectives where applicable", | |
| "", | |
| "### OUTPUT\n" | |
| "Return the LearningObjectivesOutput structure in valid JSON format.\n\n", | |
| ] | |
| ), | |
| expected_output="""JSON object with this structure: | |
| { | |
| "objectives": [ | |
| { | |
| "unit": "Unit title", | |
| "unit_description": "Brief summary of the unit scope", | |
| "unit_outcome": "One measurable Arabic objective derived from the unit description and its subtopics and their purposes", | |
| } | |
| ], | |
| }""", | |
| output_json=LearningOutcomesOutput, | |
| agent=outcomes_generator, | |
| human_input=False, | |
| ) | |