Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <danscode@selman.org>
  • Loading branch information
dselman committed May 20, 2024
1 parent 0563543 commit 06c4c97
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 125 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ Runtime result:
- NEO4J_USER: <optional> defaults to `neo4j`

### Text Embeddings
- OPENAI_API_KEY: <optional> the OpenAI API key. If not set embeddings are not computed and written to the agreement graph and similarity search, natural language to Cypher generation ("chat with data") is not possible.
- OPENAI_API_KEY: <optional> the OpenAI API key. If not set embeddings are not computed and written to the agreement graph and similarity search, natural language to Cypher generation ("chat with data") is not possible.

## API Documentation

API documentation is available [here](./docs/README.md).
74 changes: 17 additions & 57 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,28 @@
**@accordproject/concerto-graph**[**Docs**](globals.md)
**@accordproject/concerto-graph****Docs**

***

# Concerto Graph
# @accordproject/concerto-graph

This project uses a [Concerto model](https://concerto.accordproject.org) to define the nodes and edges in a Neo4J graph database and uses the model to validate the properties on the nodes.
## Classes

![demo](demo.png)
[Demo](src/demo/index.ts)
- [GraphModel](classes/GraphModel.md)

In a few lines of code you can define a Concerto data model validated graph and perform a vector similarity search over
nodes with text content.
## Type Aliases

Concerto model (snippet):
- [Context](type-aliases/Context.md)
- [GraphModelOptions](type-aliases/GraphModelOptions.md)
- [GraphNodeProperties](type-aliases/GraphNodeProperties.md)
- [SimilarityResult](type-aliases/SimilarityResult.md)

```
concept Movie extends GraphNode {
@vector_index("summary", 1536, "COSINE")
o Double[] embedding optional
@embedding
o String summary optional
@label("IN_GENRE")
--> Genre[] genres optional
}
```
## Variables

TypeScript code:
- [ROOT\_MODEL](variables/ROOT_MODEL.md)
- [ROOT\_NAMESPACE](variables/ROOT_NAMESPACE.md)

```typescript
await graphModel.mergeNode(transaction, `${NS}.Movie`, {identifier: 'Brazil', summary: 'The film centres on Sam Lowry, a low-ranking bureaucrat trying to find a woman who appears in his dreams while he is working in a mind-numbing job and living in a small apartment, set in a dystopian world in which there is an over-reliance on poorly maintained (and rather whimsical) machines'} );

await graphModel.mergeNode(transaction, `${NS}.Genre`, {identifier: 'Comedy'} );

await graphModel.mergeRelationship(transaction, `${NS}.Movie`, 'Brazil', `${NS}.Genre`, 'Comedy', 'genres' );

await graphModel.mergeNode(transaction, `${NS}.Director`, {identifier: 'Terry Gilliam'} );
await graphModel.mergeRelationship(transaction, `${NS}.Director`, 'Terry Gilliam', `${NS}.Movie`, 'Brazil', 'directed' );

await graphModel.mergeNode(transaction, `${NS}.Actor`, {identifier: 'Jonathan Pryce'} );
await graphModel.mergeRelationship(transaction, `${NS}.Actor`, 'Jonathan Pryce', `${NS}.Movie`, 'Brazil', 'actedIn' );

const search = 'Working in a boring job and looking for love.';
const results = await graphModel.similarityQuery(`${NS}.Movie`, 'embedding', search, 3);
```
## Functions

Runtime result:

```json
[
{
identifier: 'Brazil',
content: 'The film centres on Sam Lowry, a low-ranking bureaucrat trying to find a woman who appears in his dreams while he is working in a mind-numbing job and living in a small apartment, set in a dystopian world in which there is an over-reliance on poorly maintained (and rather whimsical) machines',
score: 0.901830792427063
}
]
```

## Environment Variables

### GraphDB

- NEO4J_URL: the NEO4J URL. E.g. `neo4j+s://<DB_NAME>.databases.neo4j.io` if you are using AuraDB.
- NEO4J_PASS: your neo4j password.
- NEO4J_USER: <optional> defaults to `neo4j`

### Text Embeddings
- OPENAI_API_KEY: <optional> the OpenAI API key. If not set embeddings are not computed and written to the agreement graph and similarity search, natural language to Cypher generation ("chat with data") is not possible.
- [getObjectChecksum](functions/getObjectChecksum.md)
- [getOpenAiEmbedding](functions/getOpenAiEmbedding.md)
- [getTextChecksum](functions/getTextChecksum.md)
- [textToCypher](functions/textToCypher.md)
36 changes: 18 additions & 18 deletions docs/classes/GraphModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / GraphModel
[@accordproject/concerto-graph](../README.md) / GraphModel

# Class: GraphModel

Expand Down Expand Up @@ -31,7 +31,7 @@ Creates a new instance of GraphModel

#### Source

[graphmodel.ts:252](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L252)
[graphmodel.ts:252](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L252)

## Properties

Expand Down Expand Up @@ -65,7 +65,7 @@ the query results

#### Source

[graphmodel.ts:662](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L662)
[graphmodel.ts:662](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L662)

***

Expand All @@ -87,7 +87,7 @@ Closes a database context.

#### Source

[graphmodel.ts:295](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L295)
[graphmodel.ts:295](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L295)

***

Expand All @@ -103,7 +103,7 @@ Connects to Neo4J

#### Source

[graphmodel.ts:266](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L266)
[graphmodel.ts:266](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L266)

***

Expand All @@ -119,7 +119,7 @@ Create Neo4J constraints for the model

#### Source

[graphmodel.ts:410](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L410)
[graphmodel.ts:410](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L410)

***

Expand All @@ -133,7 +133,7 @@ Create Neo4J constraints for the model

#### Source

[graphmodel.ts:447](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L447)
[graphmodel.ts:447](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L447)

***

Expand All @@ -149,7 +149,7 @@ Create vector indexes for the model

#### Source

[graphmodel.ts:427](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L427)
[graphmodel.ts:427](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L427)

***

Expand All @@ -165,7 +165,7 @@ Delete all nodes/edges in the graph

#### Source

[graphmodel.ts:469](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L469)
[graphmodel.ts:469](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L469)

***

Expand All @@ -181,7 +181,7 @@ Drop all Neo4J indexes for the model.

#### Source

[graphmodel.ts:382](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L382)
[graphmodel.ts:382](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L382)

***

Expand All @@ -207,7 +207,7 @@ the items

#### Source

[graphmodel.ts:693](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L693)
[graphmodel.ts:693](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L693)

***

Expand Down Expand Up @@ -236,7 +236,7 @@ the graph node

#### Source

[graphmodel.ts:543](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L543)
[graphmodel.ts:543](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L543)

***

Expand Down Expand Up @@ -265,7 +265,7 @@ the source node

#### Source

[graphmodel.ts:569](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L569)
[graphmodel.ts:569](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L569)

***

Expand All @@ -290,7 +290,7 @@ a promise to a Context for the database.

#### Source

[graphmodel.ts:283](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L283)
[graphmodel.ts:283](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L283)

***

Expand All @@ -316,7 +316,7 @@ the query results

#### Source

[graphmodel.ts:516](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L516)
[graphmodel.ts:516](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L516)

***

Expand All @@ -343,7 +343,7 @@ an array of similar nodes, up to the count limit

#### Source

[graphmodel.ts:628](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L628)
[graphmodel.ts:628](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L628)

***

Expand All @@ -368,7 +368,7 @@ Performs a similarity search on nodes with text content

#### Source

[graphmodel.ts:485](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L485)
[graphmodel.ts:485](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L485)

***

Expand All @@ -392,4 +392,4 @@ the Cypher query

#### Source

[graphmodel.ts:651](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L651)
[graphmodel.ts:651](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L651)
4 changes: 2 additions & 2 deletions docs/functions/getObjectChecksum.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / getObjectChecksum
[@accordproject/concerto-graph](../README.md) / getObjectChecksum

# Function: getObjectChecksum()

Expand All @@ -24,4 +24,4 @@ the identifier as a string

## Source

[graphmodel.ts:165](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L165)
[graphmodel.ts:165](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L165)
4 changes: 2 additions & 2 deletions docs/functions/getOpenAiEmbedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / getOpenAiEmbedding
[@accordproject/concerto-graph](../README.md) / getOpenAiEmbedding

# Function: getOpenAiEmbedding()

Expand All @@ -25,4 +25,4 @@ a promise to an array of numbers

## Source

[graphmodel.ts:53](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L53)
[graphmodel.ts:53](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L53)
4 changes: 2 additions & 2 deletions docs/functions/getTextChecksum.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / getTextChecksum
[@accordproject/concerto-graph](../README.md) / getTextChecksum

# Function: getTextChecksum()

Expand All @@ -24,4 +24,4 @@ the checksum

## Source

[graphmodel.ts:178](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L178)
[graphmodel.ts:178](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L178)
4 changes: 2 additions & 2 deletions docs/functions/textToCypher.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / textToCypher
[@accordproject/concerto-graph](../README.md) / textToCypher

# Function: textToCypher()

Expand All @@ -26,4 +26,4 @@ a promise to the Cypher query or null

## Source

[graphmodel.ts:70](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L70)
[graphmodel.ts:70](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L70)
28 changes: 0 additions & 28 deletions docs/globals.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/type-aliases/Context.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / Context
[@accordproject/concerto-graph](../README.md) / Context

# Type alias: Context

Expand All @@ -18,4 +18,4 @@ Runtime context
## Source

[graphmodel.ts:25](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L25)
[graphmodel.ts:25](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L25)
4 changes: 2 additions & 2 deletions docs/type-aliases/GraphModelOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / GraphModelOptions
[@accordproject/concerto-graph](../README.md) / GraphModelOptions

# Type alias: GraphModelOptions

Expand Down Expand Up @@ -38,4 +38,4 @@ Graph model options, used to configure Concerto Graph
## Source

[graphmodel.ts:208](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L208)
[graphmodel.ts:208](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L208)
4 changes: 2 additions & 2 deletions docs/type-aliases/GraphNodeProperties.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

***

[@accordproject/concerto-graph](../globals.md) / GraphNodeProperties
[@accordproject/concerto-graph](../README.md) / GraphNodeProperties

# Type alias: GraphNodeProperties

Expand All @@ -12,4 +12,4 @@ The properties allowed on graph nodes

## Source

[graphmodel.ts:190](https://github.com/accordproject/lab-concerto-graph/blob/cefc9be4fd1dac498d9d3b8abf33d069293dcc53/src/graphmodel.ts#L190)
[graphmodel.ts:190](https://github.com/accordproject/lab-concerto-graph/blob/0563543f1fdc8f8f027cd4b4eb91d11b07eff3b4/src/graphmodel.ts#L190)
Loading

0 comments on commit 06c4c97

Please sign in to comment.