Skip to content

Commit

Permalink
Fix/dynamic search hierarchy maps (#1591)
Browse files Browse the repository at this point in the history
* Fix community hierarchy maps creation

* Semver
  • Loading branch information
AlonsoGuevara authored Jan 8, 2025
1 parent 6eca5ec commit 368acc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .semversioner/next-release/patch-20250107232217157858.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "patch",
"description": "Fix a bug on creating community hierarchy for dynamic search"
}
8 changes: 6 additions & 2 deletions graphrag/query/context_builder/dynamic_community_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,22 @@ def __init__(
self.reports = {report.community_id: report for report in community_reports}
# mapping from community to sub communities
self.node2children = {
community.id: (
community.short_id: (
[]
if community.sub_community_ids is None
else community.sub_community_ids
else [str(x) for x in community.sub_community_ids]
)
for community in communities
if community.short_id is not None
}

# mapping from community to parent community
self.node2parent: dict[str, str] = {
sub_community: community
for community, sub_communities in self.node2children.items()
for sub_community in sub_communities
}

# mapping from level to communities
self.levels: dict[str, list[str]] = {}

Expand Down Expand Up @@ -182,5 +185,6 @@ async def select(self, query: str) -> tuple[list[CommunityReport], dict[str, Any
llm_info["prompt_tokens"],
llm_info["output_tokens"],
)

llm_info["ratings"] = ratings
return community_reports, llm_info

0 comments on commit 368acc1

Please sign in to comment.