Fix: Flatten results from update_community calls

- Fixed ValueError when update_communities=True
- semaphore_gather returns a list of tuples, not a single tuple
- Added proper unpacking and flattening logic
- Bug was introduced in commit dcc9da3

Resolves issue where update_communities parameter would fail with:
'ValueError: not enough values to unpack (expected 2, got 1)'
This commit is contained in:
remonxiao 2025-11-27 10:36:40 +08:00
parent 3ce3962e4b
commit 100a43b214

View file

@ -778,13 +778,17 @@ class Graphiti:
communities = []
community_edges = []
if update_communities:
communities, community_edges = await semaphore_gather(
results = await semaphore_gather(
*[
update_community(self.driver, self.llm_client, self.embedder, node)
for node in nodes
],
max_coroutines=self.max_coroutines,
)
# Flatten results from multiple update_community calls
for community_list, edge_list in results:
communities.extend(community_list)
community_edges.extend(edge_list)
end = time()