Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
ikwattro committed Aug 27, 2024
1 parent 46edc31 commit 1fb4418
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:<tag>`.

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"
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public CypherController(SchemaEnforcerService schemaEnforcerService) {
this.schemaEnforcerService = schemaEnforcerService;
}

@PostMapping("/cypher")
@PostMapping("/enforceSchema")
public ResponseEntity<CypherResponse> enforce(@RequestBody CypherRequest request) {
return ResponseEntity.ok(
new CypherResponse(
Expand Down

0 comments on commit 1fb4418

Please sign in to comment.