File size: 817 Bytes
4067b64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastapi import APIRouter
from llama_index.core.settings import Settings
from src.models.workflow_graph import GraphInputSchema, GraphOutputSchema
from src.workflows.graph_workflow import DesignGraphWorkflow

# configurations
router = APIRouter()

@router.get("/", response_model=GraphInputSchema)
async def read_root():
    return {'desc':"Graph Creation Workflow on User Intent is up!"}


@router.post("/design/", response_model=GraphOutputSchema)
async def interview_user(data: GraphInputSchema):
    try:

        graph_workflow = DesignGraphWorkflow(timeout=60, verbose=True)
        graph_result = await graph_workflow.run(_project_description=data.desc, llm=Settings._llm)

        return GraphOutputSchema(graph=graph_result)

    except Exception as e:
        return {"detail": f"Error processing {e}"}