Skip to content

Commit 368acc1

Browse files
Fix/dynamic search hierarchy maps (#1591)
* Fix community hierarchy maps creation * Semver
1 parent 6eca5ec commit 368acc1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "patch",
3+
"description": "Fix a bug on creating community hierarchy for dynamic search"
4+
}

graphrag/query/context_builder/dynamic_community_selection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,22 @@ def __init__(
5858
self.reports = {report.community_id: report for report in community_reports}
5959
# mapping from community to sub communities
6060
self.node2children = {
61-
community.id: (
61+
community.short_id: (
6262
[]
6363
if community.sub_community_ids is None
64-
else community.sub_community_ids
64+
else [str(x) for x in community.sub_community_ids]
6565
)
6666
for community in communities
67+
if community.short_id is not None
6768
}
69+
6870
# mapping from community to parent community
6971
self.node2parent: dict[str, str] = {
7072
sub_community: community
7173
for community, sub_communities in self.node2children.items()
7274
for sub_community in sub_communities
7375
}
76+
7477
# mapping from level to communities
7578
self.levels: dict[str, list[str]] = {}
7679

@@ -182,5 +185,6 @@ async def select(self, query: str) -> tuple[list[CommunityReport], dict[str, Any
182185
llm_info["prompt_tokens"],
183186
llm_info["output_tokens"],
184187
)
188+
185189
llm_info["ratings"] = ratings
186190
return community_reports, llm_info

0 commit comments

Comments
 (0)