Spaces:
Sleeping
Sleeping
| 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, | |
| OutcomesOutput, | |
| DNAMetadata, | |
| OutlineInput, | |
| ) | |
| router = APIRouter(prefix="/analysis", tags=["Introduction"]) | |
| # ------------------------------------ | |
| # === Agent 7:Training Generator === | |
| # ------------------------------------ | |
| def run_training( | |
| data: OutlineInput, outlines: ValidatedCurriculumOutput, outcomes: OutcomesOutput | |
| ): | |
| training_crew = Crew( | |
| agents=[intro_agent], | |
| tasks=[intro_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(), | |
| } | |
| result = training_crew.kickoff(inputs=merged_inputs) | |
| print(result.json_dict) | |
| return {"message": "Introduction Generated Well ๐", "result": result} | |