From 1fb44184c3993d9a626a3b1d3fb28df5220eb696 Mon Sep 17 00:00:00 2001 From: Christophe Willemsen Date: Tue, 27 Aug 2024 17:47:55 +0200 Subject: [PATCH] add README --- README.md | 45 +++++++++++++++++++ .../cypher/web/CypherController.java | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..cfdbad9 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Cypher Tools + +Experimental project exposing cypher tooling features as a rest service. + +## Docker image + +The docker image is available as `graphaware/cypher-tools:`. + +Ex : + +```bash +docker run --rm -it --name cypher-tools-1 -p 8080:8080 graphaware/cypher-tools:1.0.0 +``` + +## Schema enforcement + +LLM based Cypher query generation can lead to relationships being in the wrong direction, the following endpoint allows +you to fix the directions of a query based on a provided list of schema relationships. + +Example : + +**Generated query** : + +```cypher +MATCH (n:Person)-[:OWNED_BY]->(v:Vehicle) +RETURN n.name, v.model +``` + +However, the database schema has the relationship between the vehicle and the person instead `(Vehicle)-[:OWNED_BY]->(Person)` + +Fix it by calling the `cypher` endpoint + +```bash +curl --location 'http://localhost:8080/enforceSchema' \ +--header 'Content-Type: application/json' \ +--data '{"cypher": "MATCH (n:Person)-[:OWNED_BY]->(v:Vehicle) RETURN n.name, v.model", "relationships": ["(Person, LIVES_IN, City)","(Person, HAS_ACCOUNT, UserAccount)","(Vehicle, LICENCED_TO, LicensePlate)","(Vehicle, OWNED_BY, Person)"]}' +``` + +Response : + +```json +{ + "cypher": "MATCH (n:`Person`)<-[:`OWNED_BY`]-(v:`Vehicle`)\nRETURN n.name, v.model" +} +``` \ No newline at end of file diff --git a/src/main/java/com/graphaware/cypher/web/CypherController.java b/src/main/java/com/graphaware/cypher/web/CypherController.java index 386b347..333cf7e 100644 --- a/src/main/java/com/graphaware/cypher/web/CypherController.java +++ b/src/main/java/com/graphaware/cypher/web/CypherController.java @@ -16,7 +16,7 @@ public CypherController(SchemaEnforcerService schemaEnforcerService) { this.schemaEnforcerService = schemaEnforcerService; } - @PostMapping("/cypher") + @PostMapping("/enforceSchema") public ResponseEntity enforce(@RequestBody CypherRequest request) { return ResponseEntity.ok( new CypherResponse(