| import os |
| from crewai import Crew, Process |
| import json |
| from fastapi import APIRouter, HTTPException, Depends |
| from agents.analysis_phase import ( |
| objectives_generator, |
| objectives_task, |
| ) |
| from modules import ( |
| llm_g, |
| inputs, |
| ) |
| from schemas import ( |
| ValidatedCurriculumOutput, |
| DNAMetadata, |
| OutlineInput, |
| ) |
|
|
|
|
| router = APIRouter(prefix="/analysis", tags=["Objectives"]) |
|
|
|
|
| |
| |
| |
|
|
|
|
| @router.post("/objectives") |
| def run_objectives( |
| data: OutlineInput, outlines: ValidatedCurriculumOutput, units: dict |
| ): |
| agent = objectives_generator() |
| task = objectives_task(agent) |
| objectives_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, "units":units,"outlines": outlines.dict()} |
|
|
| result = objectives_crew.kickoff(inputs=merged_inputs) |
|
|
| print(result.json_dict) |
|
|
| return {"message": "Objectives Generated Well 🚀", "result": result} |
|
|