franky-v1 / src /routers /graph.py
architojha's picture
adding files
4067b64
raw
history blame contribute delete
817 Bytes
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}"}