请问class Graph里面的 def get_subgraph_data(self, entities: List[str]) -> dict:
# Return the subgraph entities data, excluding description and source_ids in entities
# If the relation connects two entities in the subgraph, it will be included
subgraph = self.kg.subgraph(entities)
# data = {"nodes": [], "edges": []}
data = {"nodes": []}
for node in subgraph.nodes(data=True):
node_data = {
"entity_name": node[1]["entity_name"],
"entity_type": node[1]["entity_type"],
}
data["nodes"].append(node_data)
# for edge in subgraph.edges(data=True):
# edge_data = {
# "src_entity_name": edge[2]["src_entity_name"],
# "tgt_entity_name": edge[2]["tgt_entity_name"],
# "relation_name": edge[2]["relation_name"],
# "weight": edge[2]["weight"],
# }
# data["edges"].append(edge_data)
return data
这部分代码,是不是在使用graph rag时应该取消注释,因为我得到了报错('df4a3d95-a9f7-58ee-8584-48b8ff161556', "'edges'"),没有edges
请问class Graph里面的 def get_subgraph_data(self, entities: List[str]) -> dict:
# Return the subgraph entities data, excluding description and source_ids in entities
# If the relation connects two entities in the subgraph, it will be included
subgraph = self.kg.subgraph(entities)
# data = {"nodes": [], "edges": []}
data = {"nodes": []}
for node in subgraph.nodes(data=True):
node_data = {
"entity_name": node[1]["entity_name"],
"entity_type": node[1]["entity_type"],
}
data["nodes"].append(node_data)
# for edge in subgraph.edges(data=True):
# edge_data = {
# "src_entity_name": edge[2]["src_entity_name"],
# "tgt_entity_name": edge[2]["tgt_entity_name"],
# "relation_name": edge[2]["relation_name"],
# "weight": edge[2]["weight"],
# }
# data["edges"].append(edge_data)
return data
这部分代码,是不是在使用graph rag时应该取消注释,因为我得到了报错('df4a3d95-a9f7-58ee-8584-48b8ff161556', "'edges'"),没有edges