From 29171c3e57f32d65689029f93fe02072c482c627 Mon Sep 17 00:00:00 2001 From: Luca Pinchetti Date: Thu, 5 Dec 2024 09:42:06 -0800 Subject: [PATCH] Allow \n in description --- fast_graphrag/_policies/_graph_upsert.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fast_graphrag/_policies/_graph_upsert.py b/fast_graphrag/_policies/_graph_upsert.py index 23b57d4..8cb160a 100644 --- a/fast_graphrag/_policies/_graph_upsert.py +++ b/fast_graphrag/_policies/_graph_upsert.py @@ -120,7 +120,7 @@ async def _upsert_node(node_id: TId, nodes: List[TEntity]) -> Optional[Tuple[TIn nodes.append(existing_node) # Resolve descriptions - node_description = " ".join((node.description for node in nodes)) + node_description = "\n".join((node.description for node in nodes)) if len(node_description) > self.config.max_node_description_size: node_description = await summarize_entity_description( @@ -133,7 +133,6 @@ async def _upsert_node(node_id: TId, nodes: List[TEntity]) -> Optional[Tuple[TIn # / TOKEN_TO_CHAR_RATIO # ), ) - node_description = node_description.replace("\n", " ") # Resolve types (pick most frequent) node_type = Counter((node.type for node in nodes)).most_common(1)[0][0] @@ -294,7 +293,7 @@ async def _merge_similar_edges( first_index = relation_indices[0] edge, index = map_incremental_to_edge[first_index] - edge.description = edges_group.description.replace("\n", " ") + edge.description = edges_group.description visited_edges[first_index] = None # None means it was visited but not marked for deletion. if edge.chunks: chunks.update(edge.chunks)