Skip to content

Commit

Permalink
Fix bug in Neo4j new enhancedSchema flag (#5622)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwee authored May 31, 2024
1 parent a2a55e2 commit b38e52c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions libs/langchain-community/src/graphs/neo4j_graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,24 @@ function formatSchema(
}
} else {
// Format node properties
formattedNodeProps = schema.nodeProps.map((el: Record<string, Any>) => {
const propsStr = el.properties
.map((prop: Record<string, Any>) => `${prop.property}: ${prop.type} `)
.join(", ");
return `${el.labels} {${propsStr} } `;
});
formattedNodeProps = Object.entries(schema.nodeProps).map(
([key, value]: [string, Any]) => {
const propsStr = value
.map((prop: Record<string, Any>) => `${prop.property}: ${prop.type}`)
.join(", ");
return `${key} {${propsStr}}`;
}
);

// Format relationship properties
formattedRelProps = schema.relProps.map((el: Record<string, Any>) => {
const propsStr = el.properties
.map((prop: Record<string, Any>) => `${prop.property}: ${prop.type} `)
.join(", ");
return `${el.type} {${propsStr} } `;
});
formattedRelProps = Object.entries(schema.relProps).map(
([key, value]: [string, Any]) => {
const propsStr = value
.map((prop: Record<string, Any>) => `${prop.property}: ${prop.type} `)
.join(", ");
return `${key} {${propsStr} } `;
}
);
}

// Format relationships
Expand Down

0 comments on commit b38e52c

Please sign in to comment.