Skip to content

Commit

Permalink
feat: implement dynamic parquet parsing and update for graphrag v1.0.0 (
Browse files Browse the repository at this point in the history
  • Loading branch information
noworneverev authored Dec 17, 2024
1 parent ce928eb commit 0e7806c
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 134 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
.env

/public/artifacts
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@types/react-dom": "^18.3.0",
"axios": "^1.7.2",
"fuse.js": "^7.0.0",
"hyparquet": "^1.1.0",
"hyparquet": "^1.6.4",
"material-react-table": "^2.13.1",
"react": "^18.3.1",
"react-app-rewired": "^2.2.1",
Expand Down
18 changes: 10 additions & 8 deletions src/app/components/DetailDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Box,
Card,
CardContent,
Chip,
Drawer,
IconButton,
Typography,
Expand Down Expand Up @@ -105,6 +106,7 @@ const DetailDrawer: React.FC<DetailDrawerProps> = ({
validAccessorKeys.add(tc.accessorKey);
}
});

validAccessorKeys.add("uuid");
return customNodeColumns.filter(
(column) =>
Expand Down Expand Up @@ -176,15 +178,19 @@ const DetailDrawer: React.FC<DetailDrawerProps> = ({
Node Information
</Typography>
<Typography>ID: {selectedNode.uuid}</Typography>
<Typography>Name: {selectedNode.name}</Typography>
<Typography>Title: {selectedNode.name}</Typography>
{selectedNode.covariate_type && (
<Typography>
Covariate Type: {selectedNode.covariate_type}
</Typography>
)}
<Typography>Type: {selectedNode.type}</Typography>
<Typography>
Type: <Chip label={selectedNode.type} size="small" />{" "}
</Typography>
{selectedNode.title && (
<Typography>Title: {selectedNode.title}</Typography>
<Typography>
Community Report Title: {selectedNode.title}
</Typography>
)}
{selectedNode.summary && (
<Typography>Summary: {selectedNode.summary}</Typography>
Expand Down Expand Up @@ -264,11 +270,7 @@ const DetailDrawer: React.FC<DetailDrawerProps> = ({
<Typography variant="subtitle1" sx={{ fontWeight: "bold" }}>
Linked Nodes
</Typography>
<DataTable
// columns={customNodeColumns}
columns={filteredColumns}
data={linkedNodes}
/>
<DataTable columns={filteredColumns} data={linkedNodes} />
</Box>
{selectedNode && (
<Box>
Expand Down
22 changes: 11 additions & 11 deletions src/app/hooks/useGraphData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ const useGraphData = (
includeCommunities: boolean,
includeCovariates: boolean
) => {
const [graphData, setGraphData] = useState<CustomGraphData>({ nodes: [], links: [] });


const [graphData, setGraphData] = useState<CustomGraphData>({ nodes: [], links: [] });
useEffect(() => {
const nodes: CustomNode[] = entities.map((entity) => ({
uuid: entity.id,
id: entity.title,
name: entity.title,
id: entity.title, // use title as id because relationships use title as source/target
name: entity.title, // legacy field for old GraphRAG 0.2.x - 0.3.x
title: entity.title, // new field for GraphRAG 0.5.0+ (change name to title)
type: entity.type,
description: entity.description,
human_readable_id: entity.human_readable_id,
Expand Down Expand Up @@ -122,10 +123,10 @@ const useGraphData = (
}

if (includeCommunities) {
const communityNodes = communities.map((community) => {
const communityNodes = communities.map((community) => {
const report = communityReports.find(
(r) => r.community.toString() === community.id.toString()
);
(r) => r.community.toString() === community.community.toString()
);
return {
uuid: community.id.toString(),
id: community.id.toString(),
Expand All @@ -143,8 +144,7 @@ const useGraphData = (
neighbors: [],
links: [],
};
});

});
communityNodes.forEach(node => nodesMap[node.id] = node);
nodes.push(...communityNodes);

Expand Down Expand Up @@ -187,8 +187,8 @@ const useGraphData = (

links.push(...communityEntityLinks);

//Add finding nodes and links
communityNodes.forEach((communityNode) => {
//Add finding nodes and links
communityNodes.forEach((communityNode) => {
if (communityNode.findings) {
communityNode.findings.forEach((finding, idx) => {
const findingNode = {
Expand Down
7 changes: 6 additions & 1 deletion src/app/models/community-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface CommunityReport {
id: string;
human_readable_id: number;
community: number;
parent?: number;
level: number;
title: string;
summary: string;
Expand Down Expand Up @@ -50,6 +51,10 @@ export const communityReportColumns: MRT_ColumnDef<CommunityReport>[] = [
accessorKey: "community",
header: "community",
},
{
accessorKey: "parent",
header: "parent",
},
{
accessorKey: "level",
header: "level",
Expand Down Expand Up @@ -84,7 +89,7 @@ export const communityReportColumns: MRT_ColumnDef<CommunityReport>[] = [
},
{
accessorKey: "full_content_json",
header: "Full Content JSON",
header: "full_content_json",
},
{
accessorKey: "period",
Expand Down
5 changes: 5 additions & 0 deletions src/app/models/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Community {
id: number;
human_readable_id: number;
community: number;
parent?: number;
level: number;
title: string;
entity_ids: string[];
Expand All @@ -26,6 +27,10 @@ export const communityColumns: MRT_ColumnDef<Community>[] = [
accessorKey: "community",
header: "community",
},
{
accessorKey: "parent",
header: "parent",
},
{
accessorKey: "level",
header: "level",
Expand Down
Loading

0 comments on commit 0e7806c

Please sign in to comment.