cognee/cognee/api/v1/users/routers/get_visualize_router.py
Boris e7644f4b3a
feat: migrate new UI to cognee (#966)
<!-- .github/pull_request_template.md -->

## Description
<!-- Provide a clear description of the changes in this PR -->

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.

---------

Co-authored-by: Igor Ilic <igorilic03@gmail.com>
2025-06-18 20:56:44 +02:00

23 lines
689 B
Python

from fastapi import APIRouter
from fastapi.responses import HTMLResponse, JSONResponse
from cognee.shared.logging_utils import get_logger
logger = get_logger()
def get_visualize_router() -> APIRouter:
router = APIRouter()
@router.get("", response_model=None)
async def visualize():
"""This endpoint is responsible for adding data to the graph."""
from cognee.api.v1.visualize import visualize_graph
try:
html_visualization = await visualize_graph()
return HTMLResponse(html_visualization)
except Exception as error:
return JSONResponse(status_code=409, content={"error": str(error)})
return router