mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-07-26 18:30:47 +00:00
27 lines
824 B
Python
27 lines
824 B
Python
![]() |
"""
|
||
|
This module contains all graph-related routes for the LightRAG API.
|
||
|
"""
|
||
|
|
||
|
from typing import Optional
|
||
|
|
||
|
from fastapi import APIRouter, Depends, HTTPException
|
||
|
|
||
|
from ..utils_api import get_api_key_dependency
|
||
|
|
||
|
router = APIRouter(tags=["graph"])
|
||
|
|
||
|
def create_graph_routes(rag, api_key: Optional[str] = None):
|
||
|
optional_api_key = get_api_key_dependency(api_key)
|
||
|
|
||
|
@router.get("/graph/label/list", dependencies=[Depends(optional_api_key)])
|
||
|
async def get_graph_labels():
|
||
|
"""Get all graph labels"""
|
||
|
return await rag.get_graph_labels()
|
||
|
|
||
|
@router.get("/graphs", dependencies=[Depends(optional_api_key)])
|
||
|
async def get_knowledge_graph(label: str):
|
||
|
"""Get knowledge graph for a specific label"""
|
||
|
return await rag.get_knowledge_graph(nodel_label=label, max_depth=100)
|
||
|
|
||
|
return router
|