Skip to content

Commit 0e7806c

Browse files
authored
feat: implement dynamic parquet parsing and update for graphrag v1.0.0 (#30)
1 parent ce928eb commit 0e7806c

File tree

10 files changed

+160
-134
lines changed

10 files changed

+160
-134
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
2424

25-
.env
25+
.env
26+
27+
/public/artifacts

package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@types/react-dom": "^18.3.0",
1818
"axios": "^1.7.2",
1919
"fuse.js": "^7.0.0",
20-
"hyparquet": "^1.1.0",
20+
"hyparquet": "^1.6.4",
2121
"material-react-table": "^2.13.1",
2222
"react": "^18.3.1",
2323
"react-app-rewired": "^2.2.1",

src/app/components/DetailDrawer.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Box,
44
Card,
55
CardContent,
6+
Chip,
67
Drawer,
78
IconButton,
89
Typography,
@@ -105,6 +106,7 @@ const DetailDrawer: React.FC<DetailDrawerProps> = ({
105106
validAccessorKeys.add(tc.accessorKey);
106107
}
107108
});
109+
108110
validAccessorKeys.add("uuid");
109111
return customNodeColumns.filter(
110112
(column) =>
@@ -176,15 +178,19 @@ const DetailDrawer: React.FC<DetailDrawerProps> = ({
176178
Node Information
177179
</Typography>
178180
<Typography>ID: {selectedNode.uuid}</Typography>
179-
<Typography>Name: {selectedNode.name}</Typography>
181+
<Typography>Title: {selectedNode.name}</Typography>
180182
{selectedNode.covariate_type && (
181183
<Typography>
182184
Covariate Type: {selectedNode.covariate_type}
183185
</Typography>
184186
)}
185-
<Typography>Type: {selectedNode.type}</Typography>
187+
<Typography>
188+
Type: <Chip label={selectedNode.type} size="small" />{" "}
189+
</Typography>
186190
{selectedNode.title && (
187-
<Typography>Title: {selectedNode.title}</Typography>
191+
<Typography>
192+
Community Report Title: {selectedNode.title}
193+
</Typography>
188194
)}
189195
{selectedNode.summary && (
190196
<Typography>Summary: {selectedNode.summary}</Typography>
@@ -264,11 +270,7 @@ const DetailDrawer: React.FC<DetailDrawerProps> = ({
264270
<Typography variant="subtitle1" sx={{ fontWeight: "bold" }}>
265271
Linked Nodes
266272
</Typography>
267-
<DataTable
268-
// columns={customNodeColumns}
269-
columns={filteredColumns}
270-
data={linkedNodes}
271-
/>
273+
<DataTable columns={filteredColumns} data={linkedNodes} />
272274
</Box>
273275
{selectedNode && (
274276
<Box>

src/app/hooks/useGraphData.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ const useGraphData = (
2121
includeCommunities: boolean,
2222
includeCovariates: boolean
2323
) => {
24-
const [graphData, setGraphData] = useState<CustomGraphData>({ nodes: [], links: [] });
25-
24+
25+
const [graphData, setGraphData] = useState<CustomGraphData>({ nodes: [], links: [] });
2626
useEffect(() => {
2727
const nodes: CustomNode[] = entities.map((entity) => ({
2828
uuid: entity.id,
29-
id: entity.title,
30-
name: entity.title,
29+
id: entity.title, // use title as id because relationships use title as source/target
30+
name: entity.title, // legacy field for old GraphRAG 0.2.x - 0.3.x
31+
title: entity.title, // new field for GraphRAG 0.5.0+ (change name to title)
3132
type: entity.type,
3233
description: entity.description,
3334
human_readable_id: entity.human_readable_id,
@@ -122,10 +123,10 @@ const useGraphData = (
122123
}
123124

124125
if (includeCommunities) {
125-
const communityNodes = communities.map((community) => {
126+
const communityNodes = communities.map((community) => {
126127
const report = communityReports.find(
127-
(r) => r.community.toString() === community.id.toString()
128-
);
128+
(r) => r.community.toString() === community.community.toString()
129+
);
129130
return {
130131
uuid: community.id.toString(),
131132
id: community.id.toString(),
@@ -143,8 +144,7 @@ const useGraphData = (
143144
neighbors: [],
144145
links: [],
145146
};
146-
});
147-
147+
});
148148
communityNodes.forEach(node => nodesMap[node.id] = node);
149149
nodes.push(...communityNodes);
150150

@@ -187,8 +187,8 @@ const useGraphData = (
187187

188188
links.push(...communityEntityLinks);
189189

190-
//Add finding nodes and links
191-
communityNodes.forEach((communityNode) => {
190+
//Add finding nodes and links
191+
communityNodes.forEach((communityNode) => {
192192
if (communityNode.findings) {
193193
communityNode.findings.forEach((finding, idx) => {
194194
const findingNode = {

src/app/models/community-report.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface CommunityReport {
99
id: string;
1010
human_readable_id: number;
1111
community: number;
12+
parent?: number;
1213
level: number;
1314
title: string;
1415
summary: string;
@@ -50,6 +51,10 @@ export const communityReportColumns: MRT_ColumnDef<CommunityReport>[] = [
5051
accessorKey: "community",
5152
header: "community",
5253
},
54+
{
55+
accessorKey: "parent",
56+
header: "parent",
57+
},
5358
{
5459
accessorKey: "level",
5560
header: "level",
@@ -84,7 +89,7 @@ export const communityReportColumns: MRT_ColumnDef<CommunityReport>[] = [
8489
},
8590
{
8691
accessorKey: "full_content_json",
87-
header: "Full Content JSON",
92+
header: "full_content_json",
8893
},
8994
{
9095
accessorKey: "period",

src/app/models/community.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface Community {
44
id: number;
55
human_readable_id: number;
66
community: number;
7+
parent?: number;
78
level: number;
89
title: string;
910
entity_ids: string[];
@@ -26,6 +27,10 @@ export const communityColumns: MRT_ColumnDef<Community>[] = [
2627
accessorKey: "community",
2728
header: "community",
2829
},
30+
{
31+
accessorKey: "parent",
32+
header: "parent",
33+
},
2934
{
3035
accessorKey: "level",
3136
header: "level",

0 commit comments

Comments
 (0)