ziadsameh32 commited on
Commit
25d29a0
·
1 Parent(s): 42856f3

Add login page

Browse files
Dockerfile CHANGED
@@ -18,4 +18,5 @@ EXPOSE 7860
18
 
19
  # استخدم Gunicorn بدلاً من uvicorn مباشرة لدعم عدة مستخدمين (Workers)
20
  # رقم 4 يعني أنه سيشغل 4 عمليات (Processes) لخدمة الطلبات في نفس الوقت
21
- CMD ["gunicorn", "app:app", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:7860", "--timeout", "120"]
 
 
18
 
19
  # استخدم Gunicorn بدلاً من uvicorn مباشرة لدعم عدة مستخدمين (Workers)
20
  # رقم 4 يعني أنه سيشغل 4 عمليات (Processes) لخدمة الطلبات في نفس الوقت
21
+ # CMD ["gunicorn", "app:app", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:7860", "--timeout", "120"]
22
+ CMD ["gunicorn", "app:app","--workers", "2","--worker-class", "uvicorn.workers.UvicornWorker","--bind", "0.0.0.0:7860","--timeout", "180"]
agents/analysis_phase/analysis.py CHANGED
@@ -76,8 +76,9 @@ def analysis_agent():
76
  verbose=True,
77
  )
78
 
 
79
  # ====== Task ======
80
- def analysis_task(agent):
81
  return Task(
82
  description="\n".join(
83
  [
 
76
  verbose=True,
77
  )
78
 
79
+
80
  # ====== Task ======
81
+ def analysis_task(analysis_agent):
82
  return Task(
83
  description="\n".join(
84
  [
agents/analysis_phase/objectives.py CHANGED
@@ -74,203 +74,203 @@ def objectives_generator():
74
 
75
  def objectives_task(objectives_agent):
76
  return Task(
77
- description=(
78
- "You have a complete and well-structured training curriculum provided in outlines: {outlines} and units details: {units}. "
79
- "Your task is to create one detailed, measurable learning objective in Arabic for each subtopic, "
80
- "aligned with Bloom’s Taxonomy and the three learning domains, and consistent with the purpose of each subtopic.\n\n"
81
- "### Step-by-Step Process\n"
82
- "1. Read the curriculum overview to understand the full learning journey.\n"
83
- "2. **Before you begin, review the complete list of Bloom’s action verbs and the three domains for each level to plan maximum diversity.**\n"
84
- "3. **Create a mental or written record of verbs as you use them to avoid repetition.**\n"
85
- "4. For each unit:\n"
86
- " a. Analyze the unit description to understand the learning scope and intended outcomes.\n"
87
- " b. For each subtopic within that unit:\n"
88
- " - Carefully read the subtopic title and its purpose.\n"
89
- " - Identify the main learning outcome (Knowledge, Skill, or Attitude/Behavior).\n"
90
- " - **First, determine the appropriate domain: Cognitive (Knowledge), Affective (Attitude), or Psychomotor (Skills).**\n"
91
- " - Choose the most suitable Bloom’s level or the appropriate level of that domain.\n"
92
- " - **From the available verbs at that level, select one that has not been used before (or only minimally used).**\n"
93
- " - Choose three relevant Bloom’s verbs that suit the abilities of {audience}.\n"
94
- " - Write one measurable learning objective in Arabic that accurately reflects the subtopic’s purpose.\n"
95
- " - **Track the chosen verb to prevent reusing it in later objectives.**\n\n"
96
- "### Requirements for the Three Learning Domains\n"
97
- "**Objectives must cover the three domains in a balanced way:**\n\n"
98
- f"**1. Cognitive Domain (Knowledge):**\n"
99
- f"{objectives_dimensions['Knowledge']['description']}\n"
100
- "**Levels:**\n"
101
- + "\n".join(
102
- [
103
- f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
104
- for level in objectives_dimensions["Knowledge"]["levels"]
105
- ]
106
- )
107
- + "\n\n"
108
- f"**2. Affective Domain (Attitude/Ability):**\n"
109
- f"{objectives_dimensions['Ability']['description']}\n"
110
- "**Levels:**\n"
111
- + "\n".join(
112
- [
113
- f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
114
- for level in objectives_dimensions["Ability"]["levels"]
115
- ]
116
- )
117
- + "\n\n"
118
- f"**3. Psychomotor Domain (Skills):**\n"
119
- f"{objectives_dimensions['Skills']['description']}\n"
120
- "**Levels:**\n"
121
- + "\n".join(
122
- [
123
- f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
124
- for level in objectives_dimensions["Skills"]["levels"]
125
- ]
126
- )
127
- + "\n\n"
128
- "### Critical Requirement: Verb Diversity \n"
129
- "**This is a top-priority rule that must be followed precisely:**\n\n"
130
- "**Verb Non-Repetition Rules:**\n"
131
- "1. **Maximize verb diversity** — each objective should ideally use a different verb than all previous ones.\n"
132
- "2. **Before selecting a verb, check:** Have I used this verb before? If yes, choose another.\n"
133
- "3. **Repeat a verb only when:**\n"
134
- " - All suitable alternative verbs in that Bloom level or domain are exhausted.\n"
135
- " - The subtopic’s content explicitly requires that verb for accuracy.\n"
136
- " - You can justify why no other verb fits.\n"
137
- "4. **Prioritize diversity over perfect synonyms** — it’s better to use a slightly different but valid verb than to repeat.\n"
138
- "5. **Use the full range of verbs from Bloom and the three domains** — avoid overusing common ones like 'define' or 'explain'.\n"
139
- "6. **Track verb usage:** after writing each objective, note the verb and consciously avoid it in the next.\n"
140
- "7. **If repetition is necessary:**\n"
141
- " - Space it out by at least 3–5 objectives.\n"
142
- " - Add a justification note in your internal reasoning.\n"
143
- " - Try using it in a different context or content area.\n\n"
144
- "### The 12 Mandatory Design Standards — Each Objective Must Meet All\n"
145
- "**Based on the detailed objectives reference document:**\n\n"
146
- "1. **Linked to the general goal:**\n"
147
- " - Every objective must connect to the course’s overall goal.\n"
148
- " - Example: If the general goal is 'Understand the concept of e-learning', "
149
- "the specific objective could be 'The trainee accurately defines e-learning.'\n\n"
150
- "2. **Measurable:**\n"
151
- " - Objectives must be assessable using measurable performance indicators or outcomes.\n"
152
- " - Correct: 'The trainee compares synchronous and asynchronous learning accurately.'\n"
153
- " - Incorrect: 'The trainee understands e-learning.' (Not measurable)\n\n"
154
- "3. **Achievable:**\n"
155
- " - Realistic, suitable for learner ability and course duration.\n"
156
- " - Correct: 'The trainee applies the steps to create a learning management account.'\n"
157
- " - Incorrect: 'The trainee develops a full e-learning system in one hour.' (Unrealistic)\n\n"
158
- "4. **Covers all three domains (Cognitive, Psychomotor, Affective):**\n"
159
- " - Cognitive: 'The trainee defines e-learning accurately.'\n"
160
- " - Psychomotor: 'The trainee practices using LMS assessment tools.'\n"
161
- " - Affective: 'The trainee demonstrates interest in participating in e-learning activities.'\n\n"
162
- "5. **Aligned with Bloom’s hierarchy:**\n"
163
- " - Objectives must progress logically from lower to higher levels (Remember → Create).\n\n"
164
- "6. **Clarity and precision:** Objective must be completely clear and specific.\n\n"
165
- "7. **Free from ambiguity:** No vague or overly complex phrasing.\n\n"
166
- "8. **Vocabulary clarity:** All terms must be understandable to {audience}.\n\n"
167
- "9. **Single, focused goal:** Each objective expresses only one learning outcome.\n"
168
- " - Correct: 'The trainee identifies the components of a virtual classroom.'\n"
169
- " - Incorrect: 'The trainee identifies and applies virtual classroom components.'\n\n"
170
- "10. **Realistic and feasible:** Achievable within program time and resources.\n\n"
171
- "11. **Consistent with program outcomes:** Must align with the general and specific learning outcomes.\n\n"
172
- "12. **Content-linked:** Directly related to the unit or module content.\n\n"
173
- "### Objective Writing Rules\n"
174
- "- One objective per subtopic — no more, no less.\n"
175
- "- Each must directly and precisely reflect the subtopic’s purpose.\n"
176
- "- Follow Bloom’s sequence within each unit (from lower to higher order thinking).\n"
177
- "- If a level doesn’t logically fit, skip it but maintain general progression.\n"
178
- "- You may combine two levels (e.g., Understand + Apply) if justified by subtopic purpose.\n"
179
- "- Start each objective with '[verb in present]' and keep length between 6–10 words.\n"
180
- "- Use verbs suitable for {audience} — e.g., children cannot 'evaluate' or 'analyze' like professionals.\n"
181
- "- **Core rule: Avoid verb repetition — use the widest possible range from all three domains.**\n"
182
- "- Ensure objectives are **measurable** and **achievable**.\n"
183
- "- Maintain linguistic clarity — no vague or double meanings.\n"
184
- "- Each objective must express only one precise learning outcome.\n\n"
185
- "### Strategies for Verb Diversity\n"
186
- "**Use these strategies to ensure maximum variety:**\n\n"
187
- "- **Alternate synonyms:**\n"
188
- " - Instead of always 'define', use: name, list, mention, identify, classify, select.\n"
189
- "- **Use less common verbs:**\n"
190
- " - Distinguish, infer, demonstrate, interpret, justify, summarize, illustrate.\n"
191
- "- **Match verbs to content type:**\n"
192
- " - Use verbs that capture the learning result precisely.\n"
193
- "- **Consult the full domain verb lists** (above) with 5–7 verbs per level.\n"
194
- "- **Distribute objectives across the three domains** — avoid focusing only on the cognitive domain.\n\n"
195
- "### Examples of Correct and Incorrect Objectives\n\n"
196
- "**Correct Examples (Good verb diversity and domain balance):**\n"
197
- "1. (Cognitive - Remember): The trainee lists five types of e-learning platforms.\n"
198
- "2. (Cognitive - Understand): The trainee distinguishes between various digital assessment tools.\n"
199
- "3. (Cognitive - Apply): The trainee applies active learning strategies in the classroom.\n"
200
- "4. (Cognitive - Understand): The trainee infers the main benefits of blended learning.\n"
201
- "5. (Psychomotor - Practice): The trainee practices designing an interactive learning activity.\n"
202
- "6. (Affective - Respond): The trainee actively participates in collaborative learning discussions.\n"
203
- "7. (Cognitive - Analyze): The trainee compares different instructional design models.\n"
204
- "8. (Psychomotor - Adapt): The trainee adjusts learning activities to meet learner needs.\n\n"
205
- "**Incorrect Examples (Verb repetition — avoid this):**\n"
206
- "1. The trainee defines the types of e-learning platforms.\n"
207
- "2. The trainee defines digital assessment tools.\n"
208
- "3. The trainee defines active learning strategies.\n"
209
- "4. The trainee defines blended learning benefits.\n"
210
- "5. The trainee defines steps of activity design.\n\n"
211
- "**Unclear or Unmeasurable Objectives:**\n"
212
- "- 'The trainee understands e-learning.' (Vague, not measurable)\n"
213
- "- 'The trainee learns how to use tools.' (Unclear — which tools?)\n"
214
- "- 'The trainee becomes an expert in instructional design.' (Unrealistic, not measurable)\n\n"
215
- "**Improved Versions:**\n"
216
- "- 'The trainee accurately defines e-learning.'\n"
217
- "- 'The trainee effectively uses LMS tools.'\n"
218
- "- 'The trainee applies instructional design principles to create a learning unit.'\n\n"
219
- "### Critical Quality Checklist — Verify Before Finalizing Each Objective:\n"
220
- "1. ✓ Is it clear and accurately expresses the intended outcome?\n"
221
- "2. ✓ Does it align with a Bloom’s level or learning domain?\n"
222
- "3. ✓ Is it free from ambiguity?\n"
223
- "4. ✓ Is all vocabulary appropriate for {audience}?\n"
224
- "5. ✓ Does it express only one learning outcome?\n"
225
- "6. ✓ Is it measurable through observable performance?\n"
226
- "7. ✓ Is it realistic and achievable?\n"
227
- "8. ✓ Does it align with the overall outcomes?\n"
228
- "9. ✓ Is it directly linked to the subtopic content?\n"
229
- "10. ✓ Is it sequenced logically (simple → complex)?\n"
230
- "11. ✓ Is it suitable for the learners’ level?\n"
231
- "12. ✓ Do all objectives collectively cover knowledge, skills, and attitudes?\n"
232
- "**13. Verb Check: Have you reused this verb? If yes, can you replace it?**\n"
233
- "**14. Domain Check: Are the objectives balanced across all three domains?**\n\n"
234
- "### Self-Reflection Requirement\n"
235
- "After generating all objectives for a unit, pause and evaluate:\n"
236
- "- Do objectives progress logically through Bloom’s levels?\n"
237
- "- **How many unique verbs did you use? Any repetition?**\n"
238
- "- **Can any repeated verbs be replaced with alternatives?**\n"
239
- "- Are verbs diverse and contextually appropriate?\n"
240
- "- **Do objectives cover all three domains evenly?**\n"
241
- "- Can an external evaluator assess each objective clearly?\n"
242
- "- Are all objectives realistic for {audience} and course duration?\n\n"
243
- "### Final Verification: Verb Diversity & Domain Balance\n"
244
- "**Before submitting your final output:**\n"
245
- "1. Count how many times each verb appears.\n"
246
- "2. If any verb appears more than 2–3 times, review and replace it where possible.\n"
247
- "3. Aim for at least 70–80% unique verbs across the entire curriculum.\n"
248
- "4. Keep a mental record of verb use for ongoing awareness.\n"
249
- "5. **Check balanced distribution:**\n"
250
- " - Cognitive (Knowledge): 50–60% of objectives\n"
251
- " - Affective (Attitude): 20–30% of objectives\n"
252
- " - Psychomotor (Skills): 20–30% of objectives\n"
253
- "6. If imbalance occurs, revisit and adjust classifications.\n\n"
254
- "### Domain-Specific Guidelines\n\n"
255
- "**When writing Cognitive (Knowledge) objectives:**\n"
256
- "- Use for topics focused on information, understanding, applying, analyzing, evaluating, or creating.\n"
257
- "- Examples: 'The trainee defines...', 'The trainee compares...', 'The trainee designs...'.\n\n"
258
- "**When writing Affective (Attitude) objectives:**\n"
259
- "- Use for topics involving values, emotions, interests, or behaviors.\n"
260
- "- Examples: 'The trainee demonstrates interest in...', 'The trainee participates actively...', 'The trainee commits to...'.\n\n"
261
- "**When writing Psychomotor (Skills) objectives:**\n"
262
- "- Use for topics requiring physical, technical, or procedural performance.\n"
263
- "- Examples: 'The trainee practices...', 'The trainee performs...', 'The trainee innovates...'.\n\n"
264
- "### Final Important Notes\n"
265
- "- **Top Priority:** Verb diversity and balanced domain distribution.\n"
266
- "- **Quality over quantity:** One well-crafted, diverse objective is better than several repetitive ones.\n"
267
- "- **Flexibility with precision:** Be flexible in verb choice but never compromise on accuracy.\n"
268
- "- **Continuous review:** Revisit objectives regularly for diversity and balance.\n"
269
- "- **Context matters:** Always choose the verb that best reflects what the learner should achieve in that specific subtopic.\n"
270
- "### OUTPUT\n"
271
- "Return the LearningObjectivesOutput structure in valid JSON format.\n\n"
272
- ),
273
- expected_output="""JSON object with this structure:
274
  {
275
  "objectives": [
276
  {
@@ -284,7 +284,7 @@ def objectives_task(objectives_agent):
284
  }
285
  ]
286
  }""",
287
- output_json=LearningObjectivesOutput,
288
- agent=objectives_generator,
289
- human_input=False,
290
- )
 
74
 
75
  def objectives_task(objectives_agent):
76
  return Task(
77
+ description=(
78
+ "You have a complete and well-structured training curriculum provided in outlines: {outlines} and units details: {units}. "
79
+ "Your task is to create one detailed, measurable learning objective in Arabic for each subtopic, "
80
+ "aligned with Bloom’s Taxonomy and the three learning domains, and consistent with the purpose of each subtopic.\n\n"
81
+ "### Step-by-Step Process\n"
82
+ "1. Read the curriculum overview to understand the full learning journey.\n"
83
+ "2. **Before you begin, review the complete list of Bloom’s action verbs and the three domains for each level to plan maximum diversity.**\n"
84
+ "3. **Create a mental or written record of verbs as you use them to avoid repetition.**\n"
85
+ "4. For each unit:\n"
86
+ " a. Analyze the unit description to understand the learning scope and intended outcomes.\n"
87
+ " b. For each subtopic within that unit:\n"
88
+ " - Carefully read the subtopic title and its purpose.\n"
89
+ " - Identify the main learning outcome (Knowledge, Skill, or Attitude/Behavior).\n"
90
+ " - **First, determine the appropriate domain: Cognitive (Knowledge), Affective (Attitude), or Psychomotor (Skills).**\n"
91
+ " - Choose the most suitable Bloom’s level or the appropriate level of that domain.\n"
92
+ " - **From the available verbs at that level, select one that has not been used before (or only minimally used).**\n"
93
+ " - Choose three relevant Bloom’s verbs that suit the abilities of {audience}.\n"
94
+ " - Write one measurable learning objective in Arabic that accurately reflects the subtopic’s purpose.\n"
95
+ " - **Track the chosen verb to prevent reusing it in later objectives.**\n\n"
96
+ "### Requirements for the Three Learning Domains\n"
97
+ "**Objectives must cover the three domains in a balanced way:**\n\n"
98
+ f"**1. Cognitive Domain (Knowledge):**\n"
99
+ f"{objectives_dimensions['Knowledge']['description']}\n"
100
+ "**Levels:**\n"
101
+ + "\n".join(
102
+ [
103
+ f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
104
+ for level in objectives_dimensions["Knowledge"]["levels"]
105
+ ]
106
+ )
107
+ + "\n\n"
108
+ f"**2. Affective Domain (Attitude/Ability):**\n"
109
+ f"{objectives_dimensions['Ability']['description']}\n"
110
+ "**Levels:**\n"
111
+ + "\n".join(
112
+ [
113
+ f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
114
+ for level in objectives_dimensions["Ability"]["levels"]
115
+ ]
116
+ )
117
+ + "\n\n"
118
+ f"**3. Psychomotor Domain (Skills):**\n"
119
+ f"{objectives_dimensions['Skills']['description']}\n"
120
+ "**Levels:**\n"
121
+ + "\n".join(
122
+ [
123
+ f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
124
+ for level in objectives_dimensions["Skills"]["levels"]
125
+ ]
126
+ )
127
+ + "\n\n"
128
+ "### Critical Requirement: Verb Diversity \n"
129
+ "**This is a top-priority rule that must be followed precisely:**\n\n"
130
+ "**Verb Non-Repetition Rules:**\n"
131
+ "1. **Maximize verb diversity** — each objective should ideally use a different verb than all previous ones.\n"
132
+ "2. **Before selecting a verb, check:** Have I used this verb before? If yes, choose another.\n"
133
+ "3. **Repeat a verb only when:**\n"
134
+ " - All suitable alternative verbs in that Bloom level or domain are exhausted.\n"
135
+ " - The subtopic’s content explicitly requires that verb for accuracy.\n"
136
+ " - You can justify why no other verb fits.\n"
137
+ "4. **Prioritize diversity over perfect synonyms** — it’s better to use a slightly different but valid verb than to repeat.\n"
138
+ "5. **Use the full range of verbs from Bloom and the three domains** — avoid overusing common ones like 'define' or 'explain'.\n"
139
+ "6. **Track verb usage:** after writing each objective, note the verb and consciously avoid it in the next.\n"
140
+ "7. **If repetition is necessary:**\n"
141
+ " - Space it out by at least 3–5 objectives.\n"
142
+ " - Add a justification note in your internal reasoning.\n"
143
+ " - Try using it in a different context or content area.\n\n"
144
+ "### The 12 Mandatory Design Standards — Each Objective Must Meet All\n"
145
+ "**Based on the detailed objectives reference document:**\n\n"
146
+ "1. **Linked to the general goal:**\n"
147
+ " - Every objective must connect to the course’s overall goal.\n"
148
+ " - Example: If the general goal is 'Understand the concept of e-learning', "
149
+ "the specific objective could be 'The trainee accurately defines e-learning.'\n\n"
150
+ "2. **Measurable:**\n"
151
+ " - Objectives must be assessable using measurable performance indicators or outcomes.\n"
152
+ " - Correct: 'The trainee compares synchronous and asynchronous learning accurately.'\n"
153
+ " - Incorrect: 'The trainee understands e-learning.' (Not measurable)\n\n"
154
+ "3. **Achievable:**\n"
155
+ " - Realistic, suitable for learner ability and course duration.\n"
156
+ " - Correct: 'The trainee applies the steps to create a learning management account.'\n"
157
+ " - Incorrect: 'The trainee develops a full e-learning system in one hour.' (Unrealistic)\n\n"
158
+ "4. **Covers all three domains (Cognitive, Psychomotor, Affective):**\n"
159
+ " - Cognitive: 'The trainee defines e-learning accurately.'\n"
160
+ " - Psychomotor: 'The trainee practices using LMS assessment tools.'\n"
161
+ " - Affective: 'The trainee demonstrates interest in participating in e-learning activities.'\n\n"
162
+ "5. **Aligned with Bloom’s hierarchy:**\n"
163
+ " - Objectives must progress logically from lower to higher levels (Remember → Create).\n\n"
164
+ "6. **Clarity and precision:** Objective must be completely clear and specific.\n\n"
165
+ "7. **Free from ambiguity:** No vague or overly complex phrasing.\n\n"
166
+ "8. **Vocabulary clarity:** All terms must be understandable to {audience}.\n\n"
167
+ "9. **Single, focused goal:** Each objective expresses only one learning outcome.\n"
168
+ " - Correct: 'The trainee identifies the components of a virtual classroom.'\n"
169
+ " - Incorrect: 'The trainee identifies and applies virtual classroom components.'\n\n"
170
+ "10. **Realistic and feasible:** Achievable within program time and resources.\n\n"
171
+ "11. **Consistent with program outcomes:** Must align with the general and specific learning outcomes.\n\n"
172
+ "12. **Content-linked:** Directly related to the unit or module content.\n\n"
173
+ "### Objective Writing Rules\n"
174
+ "- One objective per subtopic — no more, no less.\n"
175
+ "- Each must directly and precisely reflect the subtopic’s purpose.\n"
176
+ "- Follow Bloom’s sequence within each unit (from lower to higher order thinking).\n"
177
+ "- If a level doesn’t logically fit, skip it but maintain general progression.\n"
178
+ "- You may combine two levels (e.g., Understand + Apply) if justified by subtopic purpose.\n"
179
+ "- Start each objective with '[verb in present]' and keep length between 6–10 words.\n"
180
+ "- Use verbs suitable for {audience} — e.g., children cannot 'evaluate' or 'analyze' like professionals.\n"
181
+ "- **Core rule: Avoid verb repetition — use the widest possible range from all three domains.**\n"
182
+ "- Ensure objectives are **measurable** and **achievable**.\n"
183
+ "- Maintain linguistic clarity — no vague or double meanings.\n"
184
+ "- Each objective must express only one precise learning outcome.\n\n"
185
+ "### Strategies for Verb Diversity\n"
186
+ "**Use these strategies to ensure maximum variety:**\n\n"
187
+ "- **Alternate synonyms:**\n"
188
+ " - Instead of always 'define', use: name, list, mention, identify, classify, select.\n"
189
+ "- **Use less common verbs:**\n"
190
+ " - Distinguish, infer, demonstrate, interpret, justify, summarize, illustrate.\n"
191
+ "- **Match verbs to content type:**\n"
192
+ " - Use verbs that capture the learning result precisely.\n"
193
+ "- **Consult the full domain verb lists** (above) with 5–7 verbs per level.\n"
194
+ "- **Distribute objectives across the three domains** — avoid focusing only on the cognitive domain.\n\n"
195
+ "### Examples of Correct and Incorrect Objectives\n\n"
196
+ "**Correct Examples (Good verb diversity and domain balance):**\n"
197
+ "1. (Cognitive - Remember): The trainee lists five types of e-learning platforms.\n"
198
+ "2. (Cognitive - Understand): The trainee distinguishes between various digital assessment tools.\n"
199
+ "3. (Cognitive - Apply): The trainee applies active learning strategies in the classroom.\n"
200
+ "4. (Cognitive - Understand): The trainee infers the main benefits of blended learning.\n"
201
+ "5. (Psychomotor - Practice): The trainee practices designing an interactive learning activity.\n"
202
+ "6. (Affective - Respond): The trainee actively participates in collaborative learning discussions.\n"
203
+ "7. (Cognitive - Analyze): The trainee compares different instructional design models.\n"
204
+ "8. (Psychomotor - Adapt): The trainee adjusts learning activities to meet learner needs.\n\n"
205
+ "**Incorrect Examples (Verb repetition — avoid this):**\n"
206
+ "1. The trainee defines the types of e-learning platforms.\n"
207
+ "2. The trainee defines digital assessment tools.\n"
208
+ "3. The trainee defines active learning strategies.\n"
209
+ "4. The trainee defines blended learning benefits.\n"
210
+ "5. The trainee defines steps of activity design.\n\n"
211
+ "**Unclear or Unmeasurable Objectives:**\n"
212
+ "- 'The trainee understands e-learning.' (Vague, not measurable)\n"
213
+ "- 'The trainee learns how to use tools.' (Unclear — which tools?)\n"
214
+ "- 'The trainee becomes an expert in instructional design.' (Unrealistic, not measurable)\n\n"
215
+ "**Improved Versions:**\n"
216
+ "- 'The trainee accurately defines e-learning.'\n"
217
+ "- 'The trainee effectively uses LMS tools.'\n"
218
+ "- 'The trainee applies instructional design principles to create a learning unit.'\n\n"
219
+ "### Critical Quality Checklist — Verify Before Finalizing Each Objective:\n"
220
+ "1. ✓ Is it clear and accurately expresses the intended outcome?\n"
221
+ "2. ✓ Does it align with a Bloom’s level or learning domain?\n"
222
+ "3. ✓ Is it free from ambiguity?\n"
223
+ "4. ✓ Is all vocabulary appropriate for {audience}?\n"
224
+ "5. ✓ Does it express only one learning outcome?\n"
225
+ "6. ✓ Is it measurable through observable performance?\n"
226
+ "7. ✓ Is it realistic and achievable?\n"
227
+ "8. ✓ Does it align with the overall outcomes?\n"
228
+ "9. ✓ Is it directly linked to the subtopic content?\n"
229
+ "10. ✓ Is it sequenced logically (simple → complex)?\n"
230
+ "11. ✓ Is it suitable for the learners’ level?\n"
231
+ "12. ✓ Do all objectives collectively cover knowledge, skills, and attitudes?\n"
232
+ "**13. Verb Check: Have you reused this verb? If yes, can you replace it?**\n"
233
+ "**14. Domain Check: Are the objectives balanced across all three domains?**\n\n"
234
+ "### Self-Reflection Requirement\n"
235
+ "After generating all objectives for a unit, pause and evaluate:\n"
236
+ "- Do objectives progress logically through Bloom’s levels?\n"
237
+ "- **How many unique verbs did you use? Any repetition?**\n"
238
+ "- **Can any repeated verbs be replaced with alternatives?**\n"
239
+ "- Are verbs diverse and contextually appropriate?\n"
240
+ "- **Do objectives cover all three domains evenly?**\n"
241
+ "- Can an external evaluator assess each objective clearly?\n"
242
+ "- Are all objectives realistic for {audience} and course duration?\n\n"
243
+ "### Final Verification: Verb Diversity & Domain Balance\n"
244
+ "**Before submitting your final output:**\n"
245
+ "1. Count how many times each verb appears.\n"
246
+ "2. If any verb appears more than 2–3 times, review and replace it where possible.\n"
247
+ "3. Aim for at least 70–80% unique verbs across the entire curriculum.\n"
248
+ "4. Keep a mental record of verb use for ongoing awareness.\n"
249
+ "5. **Check balanced distribution:**\n"
250
+ " - Cognitive (Knowledge): 50–60% of objectives\n"
251
+ " - Affective (Attitude): 20–30% of objectives\n"
252
+ " - Psychomotor (Skills): 20–30% of objectives\n"
253
+ "6. If imbalance occurs, revisit and adjust classifications.\n\n"
254
+ "### Domain-Specific Guidelines\n\n"
255
+ "**When writing Cognitive (Knowledge) objectives:**\n"
256
+ "- Use for topics focused on information, understanding, applying, analyzing, evaluating, or creating.\n"
257
+ "- Examples: 'The trainee defines...', 'The trainee compares...', 'The trainee designs...'.\n\n"
258
+ "**When writing Affective (Attitude) objectives:**\n"
259
+ "- Use for topics involving values, emotions, interests, or behaviors.\n"
260
+ "- Examples: 'The trainee demonstrates interest in...', 'The trainee participates actively...', 'The trainee commits to...'.\n\n"
261
+ "**When writing Psychomotor (Skills) objectives:**\n"
262
+ "- Use for topics requiring physical, technical, or procedural performance.\n"
263
+ "- Examples: 'The trainee practices...', 'The trainee performs...', 'The trainee innovates...'.\n\n"
264
+ "### Final Important Notes\n"
265
+ "- **Top Priority:** Verb diversity and balanced domain distribution.\n"
266
+ "- **Quality over quantity:** One well-crafted, diverse objective is better than several repetitive ones.\n"
267
+ "- **Flexibility with precision:** Be flexible in verb choice but never compromise on accuracy.\n"
268
+ "- **Continuous review:** Revisit objectives regularly for diversity and balance.\n"
269
+ "- **Context matters:** Always choose the verb that best reflects what the learner should achieve in that specific subtopic.\n"
270
+ "### OUTPUT\n"
271
+ "Return the LearningObjectivesOutput structure in valid JSON format.\n\n"
272
+ ),
273
+ expected_output="""JSON object with this structure:
274
  {
275
  "objectives": [
276
  {
 
284
  }
285
  ]
286
  }""",
287
+ output_json=LearningObjectivesOutput,
288
+ agent=objectives_agent,
289
+ human_input=False,
290
+ )
agents/analysis_phase/outcomes.py CHANGED
@@ -303,6 +303,6 @@ def outcomes_task(outcomes_agent):
303
  ],
304
  }""",
305
  output_json=LearningOutcomesOutput,
306
- agent=outcomes_generator,
307
  human_input=False,
308
  )
 
303
  ],
304
  }""",
305
  output_json=LearningOutcomesOutput,
306
+ agent=outcomes_agent,
307
  human_input=False,
308
  )
agents/books/book_structure.py CHANGED
@@ -41,13 +41,13 @@ def book_structure_agent():
41
  # ---------------------------------
42
  def generate_book_outline_task(structure_agent):
43
  return Task(
44
- name="Generate book outline (NO content writing)",
45
- description=(
46
- """أنت تبني هيكل كتاب فقط (Outline) من بيانات الإدخال،
47
  بما يتناسب مع نوع الكتاب (تعليمي، معرفي، تطوير ذات، أعمال، أو غير خيالي)،
48
  مع مراعاة الجمهور المستهدف وطبيعة التجربة القرائية.
49
  """
50
- """تنبيه صارم:
51
  - لا تقم بإنشاء فصول (Chapters) جديدة.
52
  - لا تقم بإنشاء أقسام (Sections) جديدة.
53
  - لا تغيّر أسماء Chapters أو Sections الواردة في raw_units حرفيًا.
@@ -55,106 +55,106 @@ def generate_book_outline_task(structure_agent):
55
  - دورك يقتصر حصريًا على:
56
  • تنظيم وبناء Subsections داخل كل Section موجود.
57
  """
58
- "==============================\n"
59
- "قواعد إلزامية (معايير إعداد الكتب)\n"
60
- "==============================\n"
61
- "1) ممنوع كتابة محتوى الكتاب/شرح مطول/أمثلة تفصيلية. أنت تنتج هيكل فقط.\n"
62
- "2) الوضوح والبساطة في العناوين واللغة.\n"
63
- "3) تجنب التكديس: لا تضع أكثر من 6 محاور في القسم، ولا أكثر من 6 أقسام في الفصل.\n"
64
- "4) لا تضع أقل من 2 محاور في القسم نهائيًا.\n"
65
- "5) منع التكرار: لا تكرر نفس الفكرة بين محاور متجاورة، ولا تكرر نفس الصياغة الافتتاحية.\n"
66
- """6) التدرج:
67
  - الكتب التعليمية: من الأساسيات إلى التطبيق/التحليل
68
  - الكتب غير التعليمية: من التمهيد إلى التعمق ثم الخلاصة/التحول
69
  - يجب أن يعكس الترتيب رحلة القارئ الطبيعية
70
  """
71
- "7) ترابط منطقي بين الأقسام والمحاور (بدون قفزات مفاهيمية).\n\n"
72
- "==============================\n"
73
- "قواعد إلزامية لصياغة عناوين Subsections (مهم جدًا)\n"
74
- "==============================\n"
75
- "A) عناوين المحاور الفرعية لازم تكون:\n"
76
- " - قصيرة وواضحة (يفضل 2–6 كلمات).\n"
77
- " - غير تقليدية/غير جامدة، وتشد القارئ.\n"
78
- " - لغة بسيطة مناسبة للجمهور (ابتعد عن الأسلوب الأكاديمي الثقيل).\n"
79
- " - فكرة واحدة لكل عنوان.\n"
80
- "B) ممنوع تكرار بدايات العناوين أو الحشو اللفظي.\n"
81
- " - لا تبدأ عدة محاور بنفس الصيغة مثل: (في ظل...)، (يبرز...)، (من المعروف...)، (يتناول هذا القسم...).\n"
82
- "C) تجنب العناوين المركّبة التي تجمع محورين مختلفين في عنوان واحد.\n"
83
- " - مثال ممنوع: (تعريف الصمود النفسي وأهميته)\n"
84
- " - الصحيح: محور لتعريف المفهوم + محور مستقل للأهمية/الفوائد.\n"
85
- "D) تجنب كلمات فضفاضة أو غير دقيقة في العناوين مثل:\n"
86
- " - (الرئيسية/الأساسية) إذا كانت لا تضيف معنى.\n"
87
- "E) لا تستخدم عناوين تشبه عناوين الأبحاث (توثيق/اقتباسات/أسماء باحثين/سنوات) داخل العناوين.\n"
88
- "F) يجوز استخدام أساليب عنوان جذابة حسب نوع القسم:\n"
89
- " - سؤال تحفيزي، عبارة قصيرة، أو صياغة عملية (لكن بدون كتابة محتوى).\n\n"
90
- "==============================\n"
91
- "إدارة عدد الصفحات\n"
92
- "==============================\n"
93
- """إذا تم تمرير target_total_pages:
94
  - يجب توزيع عدد الصفحات على جميع Subsections بشكل متوازن ومنطقي
95
  - مجموع est_pages لكل Subsections = target_total_pages
96
  إذا لم يتم تمرير target_total_pages أو كانت القيمة 0:
97
  - قدّر عدد الصفحات المناسب للكتاب بناءً على عدد الفصول وعمق الموضوع ومستوى الجمهور
98
  - ثم وزّع الصفحات داخليًا على المحاور
99
  """
100
- "==============================\n"
101
- "الحفاظ على الأسماء\n"
102
- "==============================\n"
103
- """- استخدم عناوين Chapters وSections كما هي حرفيًا من raw_units.
104
  - يُمنع إعادة الصياغة أو التحسين اللغوي لعناوين Chapters/Sections.
105
  - التعديل/التحسين مسموح فقط داخل Subsections التي تنشئها.
106
  """
107
- "==============================\n"
108
- "المدخلات\n"
109
- "==============================\n"
110
- "- book_title: {book_title}\n"
111
- "- target_audience: {target_audience}\n"
112
- "- book_description: {book_description}\n"
113
- "- learning_outcomes: {learning_outcomes}\n"
114
- "- raw_units: {raw_units}\n"
115
- "- target_total_pages (optional): {target_total_pages}\n"
116
- "- example_reference (optional): {example_reference}\n\n"
117
- """ملاحظة مهمة:
118
  raw_units تمثل الهيكل النهائي للفصول والأقسام.
119
  يُمنع تعديل أو إعادة تسمية أي Unit أو Topic.
120
  Subsections فقط هي التي يتم إنشاؤها وتنظيمها.
121
  """
122
- "==============================\n"
123
- "مطلوب الإخراج (JSON صارم)\n"
124
- "==============================\n"
125
- "أخرج JSON فقط مطابق لـ BookOutlineOutput وبنفس أسماء الحقول:\n"
126
- "{\n"
127
- ' "book_title": "...",\n'
128
- ' "target_audience": "...",\n'
129
- ' "book_description": "...",\n'
130
- ' "chapters": [\n'
131
- " {\n"
132
- ' "chapter_title": "...",\n'
133
- ' "outcome": "...",\n'
134
- ' "sections": [\n'
135
- " {\n"
136
- ' "title": "...",\n'
137
- ' "overview": "...",\n'
138
- ' "subsections": [\n'
139
- " {\n"
140
- ' "title": "...",\n'
141
- ' "purpose": "...",\n'
142
- ' "suggested_queries": ["..."],\n'
143
- ' "difficulty": "basic|intermediate|advanced",\n'
144
- ' "est_pages": 1\n'
145
- " }\n"
146
- " ]\n"
147
- " }\n"
148
- " ]\n"
149
- " }\n"
150
- " ],\n"
151
- ' "outline_notes": "..."\n'
152
- ' "total_pages": 50\n'
153
- "}\n"
154
- "==============================\n"
155
- "تحقق إلزامي قبل الإخراج\n"
156
- "==============================\n"
157
- """قبل إخراج الـ JSON النهائي، راجع ما يلي بدقة:
158
  - كل Chapter يحتوي 2–6 Sections
159
  - كل Section يحتوي على 2–6 Subsections (لا أقل من 2 نهائيًا)
160
  - إذا وجدت Section تحتوي فكرة واحدة فقط:
@@ -166,9 +166,9 @@ Subsections فقط هي التي يتم إنشاؤها وتنظيمها.
166
  - لا تخرج JSON حتى تتأكد أن جميع القيود محققة
167
  - أي مخالفة ستُعد إخراجًا غير صالح
168
  """
169
- ),
170
- expected_output="Strict JSON matching BookOutlineOutput schema (NO extra keys).",
171
- output_json=BookOutlineOutput,
172
- agent=book_structure_agent,
173
- async_execution=False,
174
- )
 
41
  # ---------------------------------
42
  def generate_book_outline_task(structure_agent):
43
  return Task(
44
+ name="Generate book outline (NO content writing)",
45
+ description=(
46
+ """أنت تبني هيكل كتاب فقط (Outline) من بيانات الإدخال،
47
  بما يتناسب مع نوع الكتاب (تعليمي، معرفي، تطوير ذات، أعمال، أو غير خيالي)،
48
  مع مراعاة الجمهور المستهدف وطبيعة التجربة القرائية.
49
  """
50
+ """تنبيه صارم:
51
  - لا تقم بإنشاء فصول (Chapters) جديدة.
52
  - لا تقم بإنشاء أقسام (Sections) جديدة.
53
  - لا تغيّر أسماء Chapters أو Sections الواردة في raw_units حرفيًا.
 
55
  - دورك يقتصر حصريًا على:
56
  • تنظيم وبناء Subsections داخل كل Section موجود.
57
  """
58
+ "==============================\n"
59
+ "قواعد إلزامية (معايير إعداد الكتب)\n"
60
+ "==============================\n"
61
+ "1) ممنوع كتابة محتوى الكتاب/شرح مطول/أمثلة تفصيلية. أنت تنتج هيكل فقط.\n"
62
+ "2) الوضوح والبساطة في العناوين واللغة.\n"
63
+ "3) تجنب التكديس: لا تضع أكثر من 6 محاور في القسم، ولا أكثر من 6 أقسام في الفصل.\n"
64
+ "4) لا تضع أقل من 2 محاور في القسم نهائيًا.\n"
65
+ "5) منع التكرار: لا تكرر نفس الفكرة بين محاور متجاورة، ولا تكرر نفس الصياغة الافتتاحية.\n"
66
+ """6) التدرج:
67
  - الكتب التعليمية: من الأساسيات إلى التطبيق/التحليل
68
  - الكتب غير التعليمية: من التمهيد إلى التعمق ثم الخلاصة/التحول
69
  - يجب أن يعكس الترتيب رحلة القارئ الطبيعية
70
  """
71
+ "7) ترابط منطقي بين الأقسام والمحاور (بدون قفزات مفاهيمية).\n\n"
72
+ "==============================\n"
73
+ "قواعد إلزامية لصياغة عناوين Subsections (مهم جدًا)\n"
74
+ "==============================\n"
75
+ "A) عناوين المحاور الفرعية لازم تكون:\n"
76
+ " - قصيرة وواضحة (يفضل 2–6 كلمات).\n"
77
+ " - غير تقليدية/غير جامدة، وتشد القارئ.\n"
78
+ " - لغة بسيطة مناسبة للجمهور (ابتعد عن الأسلوب الأكاديمي الثقيل).\n"
79
+ " - فكرة واحدة لكل عنوان.\n"
80
+ "B) ممنوع تكرار بدايات العناوين أو الحشو اللفظي.\n"
81
+ " - لا تبدأ عدة محاور بنفس الصيغة مثل: (في ظل...)، (يبرز...)، (من المعروف...)، (يتناول هذا القسم...).\n"
82
+ "C) تجنب العناوين المركّبة التي تجمع محورين مختلفين في عنوان واحد.\n"
83
+ " - مثال ممنوع: (تعريف الصمود النفسي وأهميته)\n"
84
+ " - الصحيح: محور لتعريف المفهوم + محور مستقل للأهمية/الفوائد.\n"
85
+ "D) تجنب كلمات فضفاضة أو غير دقيقة في العناوين مثل:\n"
86
+ " - (الرئيسية/الأساسية) إذا كانت لا تضيف معنى.\n"
87
+ "E) لا تستخدم عناوين تشبه عناوين الأبحاث (توثيق/اقتباسات/أسماء باحثين/سنوات) داخل العناوين.\n"
88
+ "F) يجوز استخدام أساليب عنوان جذابة حسب نوع القسم:\n"
89
+ " - سؤال تحفيزي، عبارة قصيرة، أو صياغة عملية (لكن بدون كتابة محتوى).\n\n"
90
+ "==============================\n"
91
+ "إدارة عدد الصفحات\n"
92
+ "==============================\n"
93
+ """إذا تم تمرير target_total_pages:
94
  - يجب توزيع عدد الصفحات على جميع Subsections بشكل متوازن ومنطقي
95
  - مجموع est_pages لكل Subsections = target_total_pages
96
  إذا لم يتم تمرير target_total_pages أو كانت القيمة 0:
97
  - قدّر عدد الصفحات المناسب للكتاب بناءً على عدد الفصول وعمق الموضوع ومستوى الجمهور
98
  - ثم وزّع الصفحات داخليًا على المحاور
99
  """
100
+ "==============================\n"
101
+ "الحفاظ على الأسماء\n"
102
+ "==============================\n"
103
+ """- استخدم عناوين Chapters وSections كما هي حرفيًا من raw_units.
104
  - يُمنع إعادة الصياغة أو التحسين اللغوي لعناوين Chapters/Sections.
105
  - التعديل/التحسين مسموح فقط داخل Subsections التي تنشئها.
106
  """
107
+ "==============================\n"
108
+ "المدخلات\n"
109
+ "==============================\n"
110
+ "- book_title: {book_title}\n"
111
+ "- target_audience: {target_audience}\n"
112
+ "- book_description: {book_description}\n"
113
+ "- learning_outcomes: {learning_outcomes}\n"
114
+ "- raw_units: {raw_units}\n"
115
+ "- target_total_pages (optional): {target_total_pages}\n"
116
+ "- example_reference (optional): {example_reference}\n\n"
117
+ """ملاحظة مهمة:
118
  raw_units تمثل الهيكل النهائي للفصول والأقسام.
119
  يُمنع تعديل أو إعادة تسمية أي Unit أو Topic.
120
  Subsections فقط هي التي يتم إنشاؤها وتنظيمها.
121
  """
122
+ "==============================\n"
123
+ "مطلوب الإخراج (JSON صارم)\n"
124
+ "==============================\n"
125
+ "أخرج JSON فقط مطابق لـ BookOutlineOutput وبنفس أسماء الحقول:\n"
126
+ "{\n"
127
+ ' "book_title": "...",\n'
128
+ ' "target_audience": "...",\n'
129
+ ' "book_description": "...",\n'
130
+ ' "chapters": [\n'
131
+ " {\n"
132
+ ' "chapter_title": "...",\n'
133
+ ' "outcome": "...",\n'
134
+ ' "sections": [\n'
135
+ " {\n"
136
+ ' "title": "...",\n'
137
+ ' "overview": "...",\n'
138
+ ' "subsections": [\n'
139
+ " {\n"
140
+ ' "title": "...",\n'
141
+ ' "purpose": "...",\n'
142
+ ' "suggested_queries": ["..."],\n'
143
+ ' "difficulty": "basic|intermediate|advanced",\n'
144
+ ' "est_pages": 1\n'
145
+ " }\n"
146
+ " ]\n"
147
+ " }\n"
148
+ " ]\n"
149
+ " }\n"
150
+ " ],\n"
151
+ ' "outline_notes": "..."\n'
152
+ ' "total_pages": 50\n'
153
+ "}\n"
154
+ "==============================\n"
155
+ "تحقق إلزامي قبل الإخراج\n"
156
+ "==============================\n"
157
+ """قبل إخراج الـ JSON النهائي، راجع ما يلي بدقة:
158
  - كل Chapter يحتوي 2–6 Sections
159
  - كل Section يحتوي على 2–6 Subsections (لا أقل من 2 نهائيًا)
160
  - إذا وجدت Section تحتوي فكرة واحدة فقط:
 
166
  - لا تخرج JSON حتى تتأكد أن جميع القيود محققة
167
  - أي مخالفة ستُعد إخراجًا غير صالح
168
  """
169
+ ),
170
+ expected_output="Strict JSON matching BookOutlineOutput schema (NO extra keys).",
171
+ output_json=BookOutlineOutput,
172
+ agent=structure_agent,
173
+ async_execution=False,
174
+ )
agents/books/intro_plan.py CHANGED
@@ -23,29 +23,29 @@ def intro_style_planner():
23
  memory=False,
24
  )
25
 
26
- def intro_style_planner_task(intro_style_planner_agent, book_plan):
27
  return Task(
28
- description=(
29
- "You are given a FULL BOOK PLAN containing ALL chapters.\n\n"
30
- "Your job is NOT to analyze text.\n"
31
- "Your job is to DESIGN the most suitable introduction style for EACH chapter.\n\n"
32
- "### Goals:\n"
33
- "1) Each chapter must receive a StyleOutput profile.\n"
34
- "2) Styles MUST fit the chapter topic and emotional intent.\n"
35
- "3) Styles MUST NOT repeat across chapters.\n"
36
- "4) Consecutive chapters MUST NOT share the same intro_function.\n"
37
- "5) The book must feel rhythmically varied (narrative → reflective → conceptual → atmospheric → etc).\n\n"
38
- "### Diversity Rules (HARD CONSTRAINTS):\n"
39
- "- Do NOT repeat the same intro_function more than once.\n"
40
- "- Do NOT reuse identical tone or sentence_structure in adjacent chapters.\n"
41
- "- Vary opening strategies: story, scene, question, metaphor, reflection, contrast.\n\n"
42
- "### Output:\n"
43
- "Return ONE JSON object for the whole book using IntroStylePlan schema.\n\n"
44
- "Input book chapters:\n"
45
- "{book_plan}"
46
- ),
47
- agent=intro_style_planner,
48
- expected_output="A valid JSON following IntroPlan schema with inferred intro-writing rules",
49
- output_json=IntroPlan,
50
- # output_file=os.path.join(output_dir, "style_output_2.json"),
51
- )
 
23
  memory=False,
24
  )
25
 
26
+ def intro_style_planner_task(intro_style_planner_agent):
27
  return Task(
28
+ description=(
29
+ "You are given a FULL BOOK PLAN containing ALL chapters.\n\n"
30
+ "Your job is NOT to analyze text.\n"
31
+ "Your job is to DESIGN the most suitable introduction style for EACH chapter.\n\n"
32
+ "### Goals:\n"
33
+ "1) Each chapter must receive a StyleOutput profile.\n"
34
+ "2) Styles MUST fit the chapter topic and emotional intent.\n"
35
+ "3) Styles MUST NOT repeat across chapters.\n"
36
+ "4) Consecutive chapters MUST NOT share the same intro_function.\n"
37
+ "5) The book must feel rhythmically varied (narrative → reflective → conceptual → atmospheric → etc).\n\n"
38
+ "### Diversity Rules (HARD CONSTRAINTS):\n"
39
+ "- Do NOT repeat the same intro_function more than once.\n"
40
+ "- Do NOT reuse identical tone or sentence_structure in adjacent chapters.\n"
41
+ "- Vary opening strategies: story, scene, question, metaphor, reflection, contrast.\n\n"
42
+ "### Output:\n"
43
+ "Return ONE JSON object for the whole book using IntroStylePlan schema.\n\n"
44
+ "Input book chapters:\n"
45
+ "{book_plan}"
46
+ ),
47
+ agent=intro_style_planner_agent,
48
+ expected_output="A valid JSON following IntroPlan schema with inferred intro-writing rules",
49
+ output_json=IntroPlan,
50
+ # output_file=os.path.join(output_dir, "style_output_2.json"),
51
+ )
agents/books/units_intro.py CHANGED
@@ -306,193 +306,152 @@ def intro_generator():
306
 
307
  def intro_generation_task(intro_generator_agent):
308
  return Task(
309
- description=(
310
- "You are given structured chapters metadata:\n({chapter_metadata})\n andfocus on intros style for each chapter:\n({intro_style})\n\n"
311
-
312
- "CRITICAL WRITING RULE Opening Diversity:\n"
313
-
314
- "Even if the tone is academic or formal,"
315
- "MANDATORY HOOK:\n"
316
- "The first sentence MUST be engaging (question, story, scenario, or problem).\n"
317
- "Never start with a definition.\n\n"
318
-
319
- "AI-STYLE BAN:\n"
320
- "Never use cliché academic phrases or repeated textbook templates.\n"
321
- "If the sentence feels predictable, rewrite it.\n\n"
322
- "BANNED VERBS (in all conjugations):\n"
323
- "❌ يبرز / تبرز / يُبرز / نبرز / برز / بارز\n"
324
- "❌ يتجلى / تتجلى / تجلّى / متجلّي\n"
325
- "❌ يُعدّ / تُعدّ / عُدّ\n"
326
- " يُسلّط الضوء / نسلّط\n"
327
- "❌ يغوص / نغوص\n"
328
- "❌ يمتدّ النقاش / يمتدّ\n\n"
329
-
330
- "BANNED META-DESCRIPTIONS:\n"
331
- " هذا الفصل + any verb (يبرز، يقدّم، يستعرض، يتناول، يناقش)\n"
332
- "❌ نرى فيه / نُلاحظ هنا / نُتَعَرَّضُ هنا\n"
333
- "❌ يدعونا هذا + anything\n"
334
- "❌ من هنا، يصبح...\n\n"
335
-
336
- "BANNED TRANSITIONS:\n"
337
- " من خلال (find alternatives: بفضل، عبر، بواسطة، or restructure)\n"
338
- " في ظل\n"
339
- " عبر استكشاف\n\n"
340
-
341
- "**WHY THESE ARE BANNED:**\n"
342
- "These phrases describe what THE CHAPTER DOES.\n"
343
- "The introduction should describe THE CONCEPT, not the chapter's actions.\n\n"
344
-
345
-
346
- "NO DIRECT ADDRESS:\n"
347
- "Do not explicitly mention the audience (طلاب، متعلمون، قرّاء).\n"
348
- "Use implicit contextual framing instead.\n\n"
349
-
350
- "ARABIC QUALITY:\n"
351
- "Zero spelling, grammar, or phrasing mistakes are allowed.\n"
352
- "DO NOT use full tashkeel (vocalization marks) except:\n"
353
- "- To disambiguate rare cases\n"
354
- "- On the last word of a sentence if needed\n\n"
355
-
356
- "Academic writing does NOT mean identical openings.\n"
357
- "Each chapter MUST begin with a naturally varied opening strategy.\n"
358
- "Before writing, internally choose ONE opening style that best fits the chapter according to what style says:\n"
359
- "- contextual background\n"
360
- "- problem framing\n"
361
- "- conceptual importance\n"
362
- "- analytical contrast\n"
363
- "- research observation\n"
364
- "- structural preview\n\n"
365
- "=============================\n"
366
- "AUDIENCE RULE (REINFORCED)\n"
367
- "=============================\n\n"
368
-
369
- "NEVER use these terms:\n"
370
- " المتدرّب / المتدربون\n"
371
- " القارئ / القرّاء\n"
372
- " الطالب / الطلاب\n"
373
- " المتعلّم / المتعلمون\n"
374
- " الموظف / الموظفون\n\n"
375
-
376
- "**This is a BOOK, not a training course.**\n\n"
377
-
378
- "Rotate openings naturally across chapters.\n"
379
- "Never reuse the same opening structure repeatedly.\n"
380
- "Avoid formulaic or AI-sounding sentences.\n"
381
- "The introduction must feel written by a human author, not generated from a template.\n"
382
-
383
- "Write ONE introduction that:\n"
384
- "1) Follows the style of the chapter intro\n"
385
- "2) Reflects the learning outcome\n"
386
- "3) Frames all sections conceptually without detailing them\n"
387
- "4) Respects scope limits and avoids overlap\n"
388
- "5) Matches the declared intro_function\n\n"
389
-
390
- "CRITICAL — NO SECTION SUMMARY:\n"
391
- "Do NOT sequentially describe chapter sections.\n"
392
- "Do NOT narrate the structure of the chapter.\n"
393
- "The introduction must frame ideas, not summarize contents.\n\n"
394
-
395
- "=============================\n"
396
- "NO UNSOURCED RESEARCH CLAIMS\n"
397
- "=============================\n"
398
-
399
- "NEVER say:\n"
400
- "• تشير الدراسات\n"
401
- "• أثبتت الأبحاث\n"
402
- "• تؤكد الدراسات\n"
403
- "• يرى الباحثون\n\n"
404
-
405
- "Unless a specific study, author, or year is explicitly provided in metadata.\n"
406
- "Otherwise, discuss ideas conceptually only.\n\n"
407
-
408
-
409
- "=============================\n"
410
- "REQUIRED APPROACH\n"
411
- "=============================\n\n"
412
-
413
- "1. **START**: Hook that engages with the CONCEPT\n"
414
- " Example: 'ما الذي يجعل البعض قادرين على...؟'\n\n"
415
-
416
- "2. **DEVELOP**: Discuss the concept's nature, significance, challenges\n"
417
- " - Focus on WHAT THE CONCEPT IS\n"
418
- " - Focus on WHY IT MATTERS\n"
419
- " - Focus on HOW IT MANIFESTS\n"
420
- " - DO NOT focus on what the chapter covers\n\n"
421
-
422
- "3. **CLOSE**: Connect to reader's context or forward implication\n"
423
- " Set intellectual expectations\n"
424
- " Create forward momentum\n"
425
- " NO phrases like 'هنا نستكشف' or 'هذا الفصل يتناول'\n\n"
426
-
427
- "=============================\n"
428
- "STYLE: AVOID RIGID ACADEMIC TONE\n"
429
- "=============================\n\n"
430
-
431
- "The introduction should be:\n"
432
- " Intellectually engaging (not dry)\n"
433
- " Fluid and connected (not choppy)\n"
434
- " Conceptually rich (not procedurally descriptive)\n"
435
- " Human-sounding (not research-report style)\n\n"
436
-
437
- " RIGID ACADEMIC STYLE:\n"
438
- "'يُعرّف الصمود بأنه قدرة الفرد على التعافي. تشير الدراسات إلى دوره في الأداء.'\n\n"
439
-
440
- "✅ FLUID ENGAGING STYLE:\n"
441
- "'الصمود ليس مجرد قدرة على التحمّل، بل هو فنّ إعادة البناء الداخلي بعد كل اهتزاز.'\n\n"
442
-
443
- "=============================\n"
444
- "TRANSITIONS BETWEEN IDEAS\n"
445
- "=============================\n\n"
446
-
447
- "ALWAYS connect paragraphs smoothly.\n\n"
448
-
449
- "Use varied transition tools:\n"
450
- "• وفي هذا السياق...\n"
451
- " ومن هذا المنطلق...\n"
452
- "• وهنا تكمن...\n"
453
- "• لكن...\n"
454
- " غير أن...\n"
455
- "• بينما...\n"
456
- "• ومع ذلك...\n\n"
457
-
458
- "❌ BAD (choppy jumps):\n"
459
- "'الصمود مهم. له أركان. الشخصية الصامدة لها سمات.'\n\n"
460
-
461
- "✅ GOOD (smooth flow):\n"
462
- "'الصمود النفسي يتجاوز القوة الظاهرة. وفي أعماقه، تكمن بنية معقّدة من الأركان النفسية التي تشكّل معًا درعاً داخلياً. وهذا التماسك الداخلي هو ما يميّز...'\n\n"
463
-
464
-
465
- "STYLE REFINEMENT:\n"
466
- "Prefer conceptual language over procedural language.\n"
467
- "Avoid verbs like: يبدأ، ينتقل، يستعرض، يختتم.\n\n"
468
-
469
- "FORBIDDEN ROLES:\n"
470
- "Never use: متدرّب، مشارك، متعلم في دورة، برنامج تدريبي\n"
471
- "This is a BOOK, not training material.\n\n"
472
-
473
- 'FIELD OVERRIDES:\n'
474
- '- reader_interaction:\n'
475
- ' → Prefer conceptual engagement over direct address\n'
476
-
477
- '- opening_style includes "سؤال":\n'
478
- ' → Question MAY be implicit, not explicit\n'
479
-
480
- '- explicit_structure_markers:\n'
481
- ' → Use conceptual flow, not verbal markers\n'
482
-
483
- '- voice_type = إرشادي:\n'
484
- ' → Guide through idea progression, not instructions\n\n'
485
-
486
- "Length rules:\n"
487
- "- conceptual_explanation → 250–350 words\n"
488
- "- academic orientation → 450–750 words\n"
489
- "- analytical → 350–550 words\n\n"
490
-
491
- "Output:\n"
492
- "- JSON with a single key: intro"
493
- ),
494
- agent=intro_generator,
495
- expected_output="ChapterIntro JSON",
496
- output_json=ChapterIntro,
497
- # output_file=os.path.join(output_dir, "intro_output.json")
498
- )
 
306
 
307
  def intro_generation_task(intro_generator_agent):
308
  return Task(
309
+ description=(
310
+ "You are given structured chapters metadata:\n({chapter_metadata})\n andfocus on intros style for each chapter:\n({intro_style})\n\n"
311
+ "CRITICAL WRITING RULE — Opening Diversity:\n"
312
+ "Even if the tone is academic or formal,"
313
+ "MANDATORY HOOK:\n"
314
+ "The first sentence MUST be engaging (question, story, scenario, or problem).\n"
315
+ "Never start with a definition.\n\n"
316
+ "AI-STYLE BAN:\n"
317
+ "Never use cliché academic phrases or repeated textbook templates.\n"
318
+ "If the sentence feels predictable, rewrite it.\n\n"
319
+ "BANNED VERBS (in all conjugations):\n"
320
+ " يبرز / تبرز / يُبرز / نبرز / برز / بارز\n"
321
+ " يتجلى / تتجلى / تجلّى / متجلّي\n"
322
+ " يُعدّ / تُعدّ / عُدّ\n"
323
+ "❌ يُسلّط الضوء / نسلّط\n"
324
+ "❌ يغوص / نغوص\n"
325
+ "❌ يمتدّ النقاش / يمتدّ\n\n"
326
+ "BANNED META-DESCRIPTIONS:\n"
327
+ "❌ هذا الفصل + any verb (يبرز، يقدّم، يستعرض، يتناول، يناقش)\n"
328
+ "❌ نرى فيه / نُلاحظ هنا / نُتَعَرَّضُ هنا\n"
329
+ "❌ يدعونا هذا + anything\n"
330
+ " من هنا، يصبح...\n\n"
331
+ "BANNED TRANSITIONS:\n"
332
+ "❌ من خلال (find alternatives: بفضل، عبر، بواسطة، or restructure)\n"
333
+ "❌ في ظل\n"
334
+ "❌ عبر استكشاف\n\n"
335
+ "**WHY THESE ARE BANNED:**\n"
336
+ "These phrases describe what THE CHAPTER DOES.\n"
337
+ "The introduction should describe THE CONCEPT, not the chapter's actions.\n\n"
338
+ "NO DIRECT ADDRESS:\n"
339
+ "Do not explicitly mention the audience (طلاب، متعلمون، قرّاء).\n"
340
+ "Use implicit contextual framing instead.\n\n"
341
+ "ARABIC QUALITY:\n"
342
+ "Zero spelling, grammar, or phrasing mistakes are allowed.\n"
343
+ "DO NOT use full tashkeel (vocalization marks) except:\n"
344
+ "- To disambiguate rare cases\n"
345
+ "- On the last word of a sentence if needed\n\n"
346
+ "Academic writing does NOT mean identical openings.\n"
347
+ "Each chapter MUST begin with a naturally varied opening strategy.\n"
348
+ "Before writing, internally choose ONE opening style that best fits the chapter according to what style says:\n"
349
+ "- contextual background\n"
350
+ "- problem framing\n"
351
+ "- conceptual importance\n"
352
+ "- analytical contrast\n"
353
+ "- research observation\n"
354
+ "- structural preview\n\n"
355
+ "=============================\n"
356
+ "AUDIENCE RULE (REINFORCED)\n"
357
+ "=============================\n\n"
358
+ "NEVER use these terms:\n"
359
+ " المتدرّب / المتدربون\n"
360
+ " القارئ / القرّاء\n"
361
+ " الطالب / الطلاب\n"
362
+ " المتعلّم / المتعلمون\n"
363
+ " الموظف / الموظفون\n\n"
364
+ "**This is a BOOK, not a training course.**\n\n"
365
+ "Rotate openings naturally across chapters.\n"
366
+ "Never reuse the same opening structure repeatedly.\n"
367
+ "Avoid formulaic or AI-sounding sentences.\n"
368
+ "The introduction must feel written by a human author, not generated from a template.\n"
369
+ "Write ONE introduction that:\n"
370
+ "1) Follows the style of the chapter intro\n"
371
+ "2) Reflects the learning outcome\n"
372
+ "3) Frames all sections conceptually without detailing them\n"
373
+ "4) Respects scope limits and avoids overlap\n"
374
+ "5) Matches the declared intro_function\n\n"
375
+ "CRITICAL — NO SECTION SUMMARY:\n"
376
+ "Do NOT sequentially describe chapter sections.\n"
377
+ "Do NOT narrate the structure of the chapter.\n"
378
+ "The introduction must frame ideas, not summarize contents.\n\n"
379
+ "=============================\n"
380
+ "NO UNSOURCED RESEARCH CLAIMS\n"
381
+ "=============================\n"
382
+ "NEVER say:\n"
383
+ " تشير الدراسات\n"
384
+ " أثبتت الأبحاث\n"
385
+ " تؤكد الدراسات\n"
386
+ " يرى الباحثون\n\n"
387
+ "Unless a specific study, author, or year is explicitly provided in metadata.\n"
388
+ "Otherwise, discuss ideas conceptually only.\n\n"
389
+ "=============================\n"
390
+ "REQUIRED APPROACH\n"
391
+ "=============================\n\n"
392
+ "1. **START**: Hook that engages with the CONCEPT\n"
393
+ " Example: 'ما الذي يجعل البعض قادرين على...؟'\n\n"
394
+ "2. **DEVELOP**: Discuss the concept's nature, significance, challenges\n"
395
+ " - Focus on WHAT THE CONCEPT IS\n"
396
+ " - Focus on WHY IT MATTERS\n"
397
+ " - Focus on HOW IT MANIFESTS\n"
398
+ " - DO NOT focus on what the chapter covers\n\n"
399
+ "3. **CLOSE**: Connect to reader's context or forward implication\n"
400
+ " Set intellectual expectations\n"
401
+ " Create forward momentum\n"
402
+ " NO phrases like 'هنا نستكشف' or 'هذا الفصل يتناول'\n\n"
403
+ "=============================\n"
404
+ "STYLE: AVOID RIGID ACADEMIC TONE\n"
405
+ "=============================\n\n"
406
+ "The introduction should be:\n"
407
+ "• Intellectually engaging (not dry)\n"
408
+ "• Fluid and connected (not choppy)\n"
409
+ "• Conceptually rich (not procedurally descriptive)\n"
410
+ " Human-sounding (not research-report style)\n\n"
411
+ "❌ RIGID ACADEMIC STYLE:\n"
412
+ "'يُعرّف الصمود بأنه قدرة الفرد على التعافي. تشير الدراسات إلى دوره في الأداء.'\n\n"
413
+ " FLUID ENGAGING STYLE:\n"
414
+ "'الصمود ليس مجرد قدرة على التحمّل، بل هو فنّ إعادة البناء الداخلي بعد كل اهتزاز.'\n\n"
415
+ "=============================\n"
416
+ "TRANSITIONS BETWEEN IDEAS\n"
417
+ "=============================\n\n"
418
+ "ALWAYS connect paragraphs smoothly.\n\n"
419
+ "Use varied transition tools:\n"
420
+ " وفي هذا السياق...\n"
421
+ "• ومن هذا المنطلق...\n"
422
+ " وهنا تكمن...\n"
423
+ "• لكن...\n"
424
+ "• غير ��ن...\n"
425
+ "• بينما...\n"
426
+ "• ومع ذلك...\n\n"
427
+ "❌ BAD (choppy jumps):\n"
428
+ "'الصمود مهم. له أركان. الشخصية الصامدة لها سمات.'\n\n"
429
+ "✅ GOOD (smooth flow):\n"
430
+ "'الصمود النفسي يتجاوز القوة الظاهرة. وفي أعماقه، تكمن بنية معقّدة من الأركان النفسية التي تشكّل معًا درعاً داخلياً. وهذا التماسك الداخلي هو ما يميّز...'\n\n"
431
+ "STYLE REFINEMENT:\n"
432
+ "Prefer conceptual language over procedural language.\n"
433
+ "Avoid verbs like: يبدأ، ينتقل، يستعرض، يختتم.\n\n"
434
+ "FORBIDDEN ROLES:\n"
435
+ "Never use: متدرّب، مشارك، متعلم في دورة، برنامج تدريبي\n"
436
+ "This is a BOOK, not training material.\n\n"
437
+ "FIELD OVERRIDES:\n"
438
+ "- reader_interaction:\n"
439
+ " → Prefer conceptual engagement over direct address\n"
440
+ '- opening_style includes "سؤال":\n'
441
+ " Question MAY be implicit, not explicit\n"
442
+ "- explicit_structure_markers:\n"
443
+ " → Use conceptual flow, not verbal markers\n"
444
+ "- voice_type = إرشادي:\n"
445
+ " → Guide through idea progression, not instructions\n\n"
446
+ "Length rules:\n"
447
+ "- conceptual_explanation 250–350 words\n"
448
+ "- academic orientation → 450–750 words\n"
449
+ "- analytical 350–550 words\n\n"
450
+ "Output:\n"
451
+ "- JSON with a single key: intro"
452
+ ),
453
+ agent=intro_generator_agent,
454
+ expected_output="ChapterIntro JSON",
455
+ output_json=ChapterIntro,
456
+ # output_file=os.path.join(output_dir, "intro_output.json")
457
+ )