File size: 1,331 Bytes
325b94c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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 ===
# ------------------------------------


@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}