Spaces:
Sleeping
Sleeping
| from crewai import Agent, Task, Crew, Process, LLM | |
| import os | |
| import json | |
| from modules import llm | |
| # ====== Agent ====== | |
| report_agent = Agent( | |
| role="Training Report Builder", | |
| goal="\n".join( | |
| [ | |
| "Take the outputs from title_agent, outline_agent, training_agent, and analysis_agent.", | |
| "Generate a well-structured HTML report in Arabic.", | |
| "", | |
| "Rules:", | |
| "- At the very top of the page, display the title from title_agent output as a main heading (<h1>).", | |
| "- The training_agent introduction should appear under a section titled: 'المقدمة'.", | |
| "- The outline_agent output should appear under a section titled: 'محتويات الحقيبة'.", | |
| "- The training_agent learning outcomes should appear under a section titled: 'مخرجات البرنامج التدريبي'.", | |
| "- The analysis_agent output should appear under a section titled: 'مرحلة التحليل'.", | |
| "", | |
| "For the 'مرحلة التحليل' section:", | |
| "- Present it inside an HTML table.", | |
| "- The table should have two columns: 'العنصر' and 'الوصف'.", | |
| "- Each row corresponds to one analysis element (الهدف، الفئة المستهدفة، الخبرات السابقة، خصائص المتدربين، الاحتياجات التدريبية، القيود، المدة الزمنية، مصادر التحليل).", | |
| "", | |
| "The final HTML page should be clean and well-structured with Arabic titles and proper formatting.", | |
| ] | |
| ), | |
| backstory="\n".join( | |
| [ | |
| "This agent acts as a report generator.", | |
| "It combines all outputs (title, outline, training outcomes, analysis) into one structured HTML training portfolio.", | |
| ] | |
| ), | |
| llm=llm, | |
| verbose=True, | |
| ) | |
| # ====== Task ====== | |
| report_task = Task( | |
| description="\n".join( | |
| [ | |
| "Build an HTML page combining all outputs:", | |
| "- At the top of the page, show the title (from title_agent output) as <h1>.", | |
| "- Section 1: 'المقدمة' → from training_agent output (introduction).", | |
| "- Section 2: 'محتويات الحقيبة' → from outline_agent output.", | |
| "- Section 3: 'مخرجات البرنامج التدريبي' → from training_agent output (learning outcomes as a bulleted list).", | |
| "- Section 4: 'مرحلة التحليل' → from analysis_agent output.", | |
| " - The analysis section must be presented inside an HTML table same as this template {html_template}.", | |
| "use css style to enhance the design more and the table responsive.", | |
| "Care about colors, headers, and fonts.", | |
| "don't change the style of analysis table", | |
| " - The table should have two columns: 'العنصر' and 'الوصف'.", | |
| " - Each row corresponds to one analysis element (goal, target audience, previous experiences, learner characteristics, training needs, constraints, duration, sources of analysis).", | |
| "", | |
| "Ensure the HTML page is clean, well-structured, and properly formatted in Arabic.", | |
| ] | |
| ), | |
| expected_output="A single HTML string with a title, three sections, and a table for the analysis section. and don't put the code in html``` ```", | |
| agent=report_agent, | |
| ) | |