| import os |
| from crewai import Crew, Process |
| import json |
| from fastapi import APIRouter, HTTPException, Depends |
| from agents.analysis_phase import ( |
| intro_agent, |
| intro_task, |
| ) |
| from modules import ( |
| llm, |
| inputs, |
| ) |
| from schemas import ( |
| ValidatedCurriculumOutput, |
| LearningOutcomesOutput, |
| DNAMetadata, |
| OutlineInput, |
| ) |
|
|
|
|
| router = APIRouter(prefix="/analysis", tags=["Introduction"]) |
|
|
| |
| |
| |
|
|
|
|
| @router.post("/introduction") |
| def run_training( |
| data: OutlineInput, |
| outlines: ValidatedCurriculumOutput, |
| outcomes: LearningOutcomesOutput, |
| units:dict, |
| ): |
| agent = intro_agent() |
| task = intro_task(agent) |
| training_crew = Crew( |
| agents=[agent], |
| tasks=[task], |
| process=Process.sequential, |
| ) |
|
|
| inputs = data.dict() |
| user_inputs = DNAMetadata( |
| topic=inputs["topic"], |
| domain=inputs["domain"], |
| content_type=inputs["content_type"], |
| audience=inputs["audience"], |
| material_type=inputs["material_type"], |
| ).dict() |
|
|
| merged_inputs = { |
| **user_inputs, |
| "outlines": outlines.dict(), |
| "outcomes": outcomes.dict(), |
| "units": units, |
| } |
| result = training_crew.kickoff(inputs=merged_inputs) |
| print(result.json_dict) |
|
|
| return {"message": "Introduction Generated Well 🚀", "result": result} |
|
|