File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -375,7 +375,23 @@ async def get_knowledge_graph(
375375 KnowledgeGraph: Knowledge graph containing nodes and edges
376376 """
377377
378- return await self .chunk_entity_relation_graph .get_knowledge_graph (node_label , max_depth , max_nodes )
378+ kg = await self .chunk_entity_relation_graph .get_knowledge_graph (node_label , max_depth , max_nodes )
379+
380+ # Clean up descriptions in nodes by replacing GRAPH_FIELD_SEP with double newlines
381+ if kg .nodes and len (kg .nodes ) > 0 :
382+ for node in kg .nodes :
383+ if node .properties .get ("description" ):
384+ # Replace <SEP> with double newlines for better readability
385+ node .properties ["description" ] = node .properties ["description" ].replace (GRAPH_FIELD_SEP , "\n \n " )
386+
387+ # Clean up descriptions in edges by replacing GRAPH_FIELD_SEP with double newlines
388+ if kg .edges and len (kg .edges ) > 0 :
389+ for edge in kg .edges :
390+ if edge .properties .get ("description" ):
391+ # Replace <SEP> with double newlines for better readability
392+ edge .properties ["description" ] = edge .properties ["description" ].replace (GRAPH_FIELD_SEP , "\n \n " )
393+
394+ return kg
379395
380396 def _get_storage_class (self , storage_name : str ) -> Callable [..., Any ]:
381397 # Direct class lookup from registry instead of dynamic import
Original file line number Diff line number Diff line change 2020from aperag .db .ops import async_db_ops
2121from aperag .exceptions import CollectionNotFoundException
2222from aperag .graph import lightrag_manager
23+ from aperag .graph .lightrag .types import KnowledgeGraph
2324from aperag .schema import view_models
2425from aperag .utils .utils import utc_now
2526
@@ -92,7 +93,7 @@ async def get_knowledge_graph(
9293 mode_description = f"subgraph from '{ label } '"
9394
9495 # Get knowledge graph
95- kg = await rag .get_knowledge_graph (
96+ kg : KnowledgeGraph = await rag .get_knowledge_graph (
9697 node_label = node_label ,
9798 max_depth = max_depth ,
9899 max_nodes = query_max_nodes ,
You can’t perform that action at this time.
0 commit comments