Download routers/objective_route.py from aliroya32/ContiAI: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/routers/objective_route.py
- Command line
-
hf download hf://spaces/aliroya32/ContiAI/routers/objective_route.py
-
curl -L -o objective_route.py https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/routers/objective_route.py
1.33 kB
| 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"]) | |
| # ------------------------------------ | |
| # === Agent 5:Objectives Generator === | |
| # ------------------------------------ | |
| 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} | |