Skip to content

Commit

Permalink
feat: conversation and tool options
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 28, 2024
1 parent 8f4fb74 commit dba8427
Show file tree
Hide file tree
Showing 24 changed files with 259 additions and 144 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ you to ask follow-up questions. This capability exposes the GraphModel as an Ope
allowing the LLM to call into the GraphModel to answer questions.

```typescript
const convo = new Conversation(graphModel);
const convo = new Conversation(graphModel, {
toolOptions: {
getById: true,
chatWithData: true
}
});
let result = await convo.appendUserMessage('Tell me a joke about actors');
console.log(result);
result = await convo.appendUserMessage('Which actor acted in Fear and Loathing in Las Vegas?');
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Type Aliases

- [Context](type-aliases/Context.md)
- [ConversationOptions](type-aliases/ConversationOptions.md)
- [EmbeddingCacheNode](type-aliases/EmbeddingCacheNode.md)
- [EmbeddingFunction](type-aliases/EmbeddingFunction.md)
- [FullTextIndex](type-aliases/FullTextIndex.md)
Expand All @@ -20,6 +21,7 @@
- [Logger](type-aliases/Logger.md)
- [PropertyBag](type-aliases/PropertyBag.md)
- [SimilarityResult](type-aliases/SimilarityResult.md)
- [ToolOptions](type-aliases/ToolOptions.md)
- [ToolResponse](type-aliases/ToolResponse.md)
- [VectorIndex](type-aliases/VectorIndex.md)

Expand Down
7 changes: 4 additions & 3 deletions docs/classes/Conversation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ An LLM conversation about a GraphModel

### new Conversation()

> **new Conversation**(`graphModel`): [`Conversation`](Conversation.md)
> **new Conversation**(`graphModel`, `options`): [`Conversation`](Conversation.md)
Creates a new Conversation

Expand All @@ -21,14 +21,15 @@ Creates a new Conversation
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `graphModel` | [`GraphModel`](GraphModel.md) | the graph model for the conversation |
| `options` | [`ConversationOptions`](../type-aliases/ConversationOptions.md) | - |

#### Returns

[`Conversation`](Conversation.md)

#### Source

[Conversation.ts:22](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/Conversation.ts#L22)
[Conversation.ts:23](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/Conversation.ts#L23)

## Properties

Expand Down Expand Up @@ -63,4 +64,4 @@ the final result message

#### Source

[Conversation.ts:35](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/Conversation.ts#L35)
[Conversation.ts:36](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/Conversation.ts#L36)
52 changes: 29 additions & 23 deletions docs/classes/GraphModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Creates a new instance of GraphModel

#### Source

[graphmodel.ts:24](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L24)
[graphmodel.ts:24](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L24)

## Properties

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

#### Source

[graphmodel.ts:493](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L493)
[graphmodel.ts:493](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L493)

***

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

#### Source

[graphmodel.ts:67](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L67)
[graphmodel.ts:67](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L67)

***

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

#### Source

[graphmodel.ts:38](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L38)
[graphmodel.ts:38](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L38)

***

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

#### Source

[graphmodel.ts:199](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L199)
[graphmodel.ts:199](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L199)

***

Expand All @@ -135,7 +135,7 @@ Create fulltext indexes for the model

#### Source

[graphmodel.ts:269](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L269)
[graphmodel.ts:269](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L269)

***

Expand All @@ -152,7 +152,7 @@ for the model

#### Source

[graphmodel.ts:190](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L190)
[graphmodel.ts:190](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L190)

***

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

#### Source

[graphmodel.ts:251](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L251)
[graphmodel.ts:251](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L251)

***

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

#### Source

[graphmodel.ts:287](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L287)
[graphmodel.ts:287](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L287)

***

Expand All @@ -210,7 +210,7 @@ the result

#### Source

[graphmodel.ts:384](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L384)
[graphmodel.ts:384](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L384)

***

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

#### Source

[graphmodel.ts:161](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L161)
[graphmodel.ts:161](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L161)

***

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

#### Source

[graphmodel.ts:525](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L525)
[graphmodel.ts:525](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L525)

***

Expand All @@ -268,16 +268,22 @@ Get all the full text indexes for the model

#### Source

[graphmodel.ts:234](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L234)
[graphmodel.ts:234](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L234)

***

### getTools()

> **getTools**(): `RunnableToolFunction`\<`any`\>[]
> **getTools**(`options`): `RunnableToolFunction`\<`any`\>[]
Creates OpenAI tools for the model

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `options` | [`ToolOptions`](../type-aliases/ToolOptions.md) |

#### Returns

`RunnableToolFunction`\<`any`\>[]
Expand All @@ -286,7 +292,7 @@ an array of OpenAI tool definitions

#### Source

[graphmodel.ts:617](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L617)
[graphmodel.ts:617](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L617)

***

Expand All @@ -302,7 +308,7 @@ Get all the vector indexes for the model

#### Source

[graphmodel.ts:216](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L216)
[graphmodel.ts:216](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L216)

***

Expand Down Expand Up @@ -331,7 +337,7 @@ the graph node

#### Source

[graphmodel.ts:361](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L361)
[graphmodel.ts:361](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L361)

***

Expand Down Expand Up @@ -360,7 +366,7 @@ the source node

#### Source

[graphmodel.ts:399](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L399)
[graphmodel.ts:399](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L399)

***

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

#### Source

[graphmodel.ts:55](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L55)
[graphmodel.ts:55](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L55)

***

Expand All @@ -411,7 +417,7 @@ the query results

#### Source

[graphmodel.ts:334](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L334)
[graphmodel.ts:334](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L334)

***

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

#### Source

[graphmodel.ts:458](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L458)
[graphmodel.ts:458](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L458)

***

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

#### Source

[graphmodel.ts:303](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L303)
[graphmodel.ts:303](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L303)

***

Expand All @@ -487,4 +493,4 @@ the Cypher query

#### Source

[graphmodel.ts:482](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/graphmodel.ts#L482)
[graphmodel.ts:482](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/graphmodel.ts#L482)
2 changes: 1 addition & 1 deletion docs/functions/getOpenAiEmbedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ a promise to an array of numbers

## Source

[functions.ts:12](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/functions.ts#L12)
[functions.ts:12](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/functions.ts#L12)
2 changes: 1 addition & 1 deletion docs/type-aliases/Context.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Runtime context
## Source

[types.ts:34](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L34)
[types.ts:60](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L60)
19 changes: 19 additions & 0 deletions docs/type-aliases/ConversationOptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[**@accordproject/concerto-graph**](../README.md)**Docs**

***

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

# Type alias: ConversationOptions

> **ConversationOptions**: `object`
## Type declaration

### toolOptions

> **toolOptions**: [`ToolOptions`](ToolOptions.md)
## Source

[types.ts:44](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L44)
2 changes: 1 addition & 1 deletion docs/type-aliases/EmbeddingCacheNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ A Node type that is used to cache vector embeddings
## Source

[types.ts:41](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L41)
[types.ts:67](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L67)
2 changes: 1 addition & 1 deletion docs/type-aliases/EmbeddingFunction.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ vector embeddings for text

## Source

[types.ts:70](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L70)
[types.ts:96](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L96)
2 changes: 1 addition & 1 deletion docs/type-aliases/FullTextIndex.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Definition of a full text index over some properties
## Source

[types.ts:25](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L25)
[types.ts:51](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L51)
2 changes: 1 addition & 1 deletion docs/type-aliases/GraphModelOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Graph model options, used to configure Concerto Graph
## Source

[types.ts:91](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L91)
[types.ts:117](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L117)
2 changes: 1 addition & 1 deletion docs/type-aliases/GraphNodeProperties.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ The properties allowed on graph nodes

## Source

[types.ts:64](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L64)
[types.ts:90](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L90)
2 changes: 1 addition & 1 deletion docs/type-aliases/Logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ Function signature for a logger

## Source

[types.ts:75](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L75)
[types.ts:101](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L101)
2 changes: 1 addition & 1 deletion docs/type-aliases/PropertyBag.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ A untyped set of properties

## Source

[types.ts:59](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L59)
[types.ts:85](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L85)
2 changes: 1 addition & 1 deletion docs/type-aliases/SimilarityResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Result of a vector similarity search
## Source

[types.ts:50](https://github.com/accordproject/lab-concerto-graph/blob/d7fad90b4d14f7e274bc7920a0b495fb75c52dcc/src/types.ts#L50)
[types.ts:76](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L76)
41 changes: 41 additions & 0 deletions docs/type-aliases/ToolOptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[**@accordproject/concerto-graph**](../README.md)**Docs**

***

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

# Type alias: ToolOptions

> **ToolOptions**: `object`
Options for tool generation from the model

## Type declaration

### chatWithData?

> `optional` **chatWithData**: `boolean`
Creates tools to retrieve nodes via generation of Cypher from natural language

### fullTextSearch?

> `optional` **fullTextSearch**: `boolean`
Creates tools to retrieve nodes via fulltext search of indexed properties

### getById?

> `optional` **getById**: `boolean`
Creates tools to retrieve nodes by id

### similaritySearch?

> `optional` **similaritySearch**: `boolean`
Creates tools to retrieve nodes via similarity search of vector indexed properties

## Source

[types.ts:25](https://github.com/accordproject/lab-concerto-graph/blob/8f4fb74348d19b37d903f29e81aaec4eca02a552/src/types.ts#L25)
Loading

0 comments on commit dba8427

Please sign in to comment.