From 91648e75986670e16261bbc19c4f75e2a4f3c3b8 Mon Sep 17 00:00:00 2001 From: Dan Selman Date: Fri, 28 Jun 2024 15:47:45 +0100 Subject: [PATCH] feat: Conversation option for prompt Signed-off-by: Dan Selman --- docs/classes/Conversation.md | 18 +++----- docs/classes/GraphModel.md | 56 ++++++++++++------------ docs/classes/TextToGraph.md | 4 +- docs/functions/getOpenAiEmbedding.md | 2 +- docs/type-aliases/Context.md | 2 +- docs/type-aliases/ConversationOptions.md | 8 +++- docs/type-aliases/EmbeddingCacheNode.md | 2 +- docs/type-aliases/EmbeddingFunction.md | 2 +- docs/type-aliases/FullTextIndex.md | 2 +- docs/type-aliases/GraphModelOptions.md | 2 +- docs/type-aliases/GraphNodeProperties.md | 2 +- docs/type-aliases/Logger.md | 2 +- docs/type-aliases/OpenAiOptions.md | 2 +- docs/type-aliases/PropertyBag.md | 2 +- docs/type-aliases/SimilarityResult.md | 2 +- docs/type-aliases/TextToGraphOptions.md | 2 +- docs/type-aliases/ToolMessage.md | 2 +- docs/type-aliases/ToolOptions.md | 2 +- docs/type-aliases/ToolResponse.md | 2 +- docs/type-aliases/VectorIndex.md | 2 +- docs/variables/ConsoleLogger.md | 2 +- docs/variables/EMBEDDINGS_MAGIC.md | 2 +- src/Conversation.ts | 4 +- src/TextToGraph.ts | 6 +-- src/prompt.ts | 25 ----------- src/types.ts | 4 ++ 26 files changed, 70 insertions(+), 91 deletions(-) diff --git a/docs/classes/Conversation.md b/docs/classes/Conversation.md index 77f8eed..e88644c 100644 --- a/docs/classes/Conversation.md +++ b/docs/classes/Conversation.md @@ -29,7 +29,7 @@ Creates a new Conversation #### Source -[Conversation.ts:26](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/Conversation.ts#L26) +[Conversation.ts:26](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/Conversation.ts#L26) ## Properties @@ -65,22 +65,16 @@ the final result message #### Source -[Conversation.ts:81](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/Conversation.ts#L81) +[Conversation.ts:81](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/Conversation.ts#L81) *** ### getSystemMessage() -> **getSystemMessage**(`prompt`?): `object` +> **getSystemMessage**(): `object` The system message -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `prompt`? | `string` | - #### Returns `object` @@ -97,7 +91,7 @@ the system message for the conversation #### Source -[Conversation.ts:68](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/Conversation.ts#L68) +[Conversation.ts:68](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/Conversation.ts#L68) *** @@ -116,7 +110,7 @@ or undefined if a user message has not been added #### Source -[Conversation.ts:111](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/Conversation.ts#L111) +[Conversation.ts:111](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/Conversation.ts#L111) *** @@ -142,4 +136,4 @@ all the messages #### Source -[Conversation.ts:41](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/Conversation.ts#L41) +[Conversation.ts:41](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/Conversation.ts#L41) diff --git a/docs/classes/GraphModel.md b/docs/classes/GraphModel.md index bb11664..1a4ed93 100644 --- a/docs/classes/GraphModel.md +++ b/docs/classes/GraphModel.md @@ -31,7 +31,7 @@ Creates a new instance of GraphModel #### Source -[graphmodel.ts:27](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L27) +[graphmodel.ts:27](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L27) ## Properties @@ -65,7 +65,7 @@ the query results #### Source -[graphmodel.ts:609](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L609) +[graphmodel.ts:609](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L609) *** @@ -87,7 +87,7 @@ Closes a database context. #### Source -[graphmodel.ts:167](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L167) +[graphmodel.ts:167](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L167) *** @@ -103,7 +103,7 @@ Connects to Neo4J #### Source -[graphmodel.ts:43](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L43) +[graphmodel.ts:43](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L43) *** @@ -119,7 +119,7 @@ Create Neo4J constraints for the model #### Source -[graphmodel.ts:301](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L301) +[graphmodel.ts:301](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L301) *** @@ -135,7 +135,7 @@ Create fulltext indexes for the model #### Source -[graphmodel.ts:373](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L373) +[graphmodel.ts:373](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L373) *** @@ -152,7 +152,7 @@ for the model #### Source -[graphmodel.ts:292](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L292) +[graphmodel.ts:292](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L292) *** @@ -168,7 +168,7 @@ Create vector indexes for the model #### Source -[graphmodel.ts:355](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L355) +[graphmodel.ts:355](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L355) *** @@ -184,7 +184,7 @@ Delete all nodes/edges in the graph #### Source -[graphmodel.ts:391](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L391) +[graphmodel.ts:391](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L391) *** @@ -210,7 +210,7 @@ the result #### Source -[graphmodel.ts:491](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L491) +[graphmodel.ts:491](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L491) *** @@ -226,7 +226,7 @@ Drop all Neo4J indexes for the model. #### Source -[graphmodel.ts:263](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L263) +[graphmodel.ts:263](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L263) *** @@ -252,7 +252,7 @@ the items #### Source -[graphmodel.ts:643](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L643) +[graphmodel.ts:643](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L643) *** @@ -270,7 +270,7 @@ the concerto models as a string #### Source -[graphmodel.ts:590](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L590) +[graphmodel.ts:590](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L590) *** @@ -296,7 +296,7 @@ specified #### Source -[graphmodel.ts:75](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L75) +[graphmodel.ts:75](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L75) *** @@ -322,7 +322,7 @@ decorator #### Source -[graphmodel.ts:338](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L338) +[graphmodel.ts:338](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L338) *** @@ -343,7 +343,7 @@ graph nodes #### Source -[graphmodel.ts:97](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L97) +[graphmodel.ts:97](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L97) *** @@ -367,7 +367,7 @@ an array of OpenAI tool definitions #### Source -[graphmodel.ts:771](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L771) +[graphmodel.ts:771](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L771) *** @@ -393,7 +393,7 @@ decorator #### Source -[graphmodel.ts:319](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L319) +[graphmodel.ts:319](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L319) *** @@ -410,7 +410,7 @@ from the graph and populates the ModelManager #### Source -[graphmodel.ts:150](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L150) +[graphmodel.ts:150](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L150) *** @@ -428,7 +428,7 @@ promise to indicate the operation is complete #### Source -[graphmodel.ts:117](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L117) +[graphmodel.ts:117](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L117) *** @@ -457,7 +457,7 @@ the graph node #### Source -[graphmodel.ts:468](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L468) +[graphmodel.ts:468](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L468) *** @@ -486,7 +486,7 @@ the source node #### Source -[graphmodel.ts:506](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L506) +[graphmodel.ts:506](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L506) *** @@ -511,7 +511,7 @@ a promise to a Context for the database. #### Source -[graphmodel.ts:59](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L59) +[graphmodel.ts:59](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L59) *** @@ -537,7 +537,7 @@ the query results #### Source -[graphmodel.ts:438](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L438) +[graphmodel.ts:438](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L438) *** @@ -556,7 +556,7 @@ returns the concerto model from the graph #### Source -[graphmodel.ts:132](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L132) +[graphmodel.ts:132](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L132) *** @@ -583,7 +583,7 @@ an array of similar nodes, up to the count limit #### Source -[graphmodel.ts:565](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L565) +[graphmodel.ts:565](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L565) *** @@ -608,7 +608,7 @@ Performs a similarity search on nodes with text content #### Source -[graphmodel.ts:407](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L407) +[graphmodel.ts:407](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L407) *** @@ -632,4 +632,4 @@ the Cypher query #### Source -[graphmodel.ts:599](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/graphmodel.ts#L599) +[graphmodel.ts:599](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/graphmodel.ts#L599) diff --git a/docs/classes/TextToGraph.md b/docs/classes/TextToGraph.md index 84c9f2d..96ad6a0 100644 --- a/docs/classes/TextToGraph.md +++ b/docs/classes/TextToGraph.md @@ -30,7 +30,7 @@ Creates a new TextToGraph #### Source -[TextToGraph.ts:19](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/TextToGraph.ts#L19) +[TextToGraph.ts:19](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/TextToGraph.ts#L19) ## Properties @@ -69,4 +69,4 @@ an object that describes which nodes and relationships were added #### Source -[TextToGraph.ts:35](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/TextToGraph.ts#L35) +[TextToGraph.ts:36](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/TextToGraph.ts#L36) diff --git a/docs/functions/getOpenAiEmbedding.md b/docs/functions/getOpenAiEmbedding.md index 17ab313..3bd2c54 100644 --- a/docs/functions/getOpenAiEmbedding.md +++ b/docs/functions/getOpenAiEmbedding.md @@ -26,4 +26,4 @@ a promise to an array of numbers ## Source -[functions.ts:28](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/functions.ts#L28) +[functions.ts:28](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/functions.ts#L28) diff --git a/docs/type-aliases/Context.md b/docs/type-aliases/Context.md index 65221bd..6acf7c2 100644 --- a/docs/type-aliases/Context.md +++ b/docs/type-aliases/Context.md @@ -18,4 +18,4 @@ Runtime context ## Source -[types.ts:140](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L140) +[types.ts:144](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L144) diff --git a/docs/type-aliases/ConversationOptions.md b/docs/type-aliases/ConversationOptions.md index c6f74e7..8f9610f 100644 --- a/docs/type-aliases/ConversationOptions.md +++ b/docs/type-aliases/ConversationOptions.md @@ -32,6 +32,12 @@ reached Options to configure Open AI +### systemPrompt? + +> `optional` **systemPrompt**: `string` + +System prompt + ### toolOptions > **toolOptions**: [`ToolOptions`](ToolOptions.md) @@ -40,4 +46,4 @@ Which tools to register on the conversation ## Source -[types.ts:84](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L84) +[types.ts:84](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L84) diff --git a/docs/type-aliases/EmbeddingCacheNode.md b/docs/type-aliases/EmbeddingCacheNode.md index c2f8651..73ff035 100644 --- a/docs/type-aliases/EmbeddingCacheNode.md +++ b/docs/type-aliases/EmbeddingCacheNode.md @@ -26,4 +26,4 @@ A Node type that is used to cache vector embeddings ## Source -[types.ts:147](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L147) +[types.ts:151](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L151) diff --git a/docs/type-aliases/EmbeddingFunction.md b/docs/type-aliases/EmbeddingFunction.md index 51db98a..1ac8b57 100644 --- a/docs/type-aliases/EmbeddingFunction.md +++ b/docs/type-aliases/EmbeddingFunction.md @@ -24,4 +24,4 @@ vector embeddings for text ## Source -[types.ts:176](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L176) +[types.ts:180](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L180) diff --git a/docs/type-aliases/FullTextIndex.md b/docs/type-aliases/FullTextIndex.md index 9259f74..d590afb 100644 --- a/docs/type-aliases/FullTextIndex.md +++ b/docs/type-aliases/FullTextIndex.md @@ -26,4 +26,4 @@ Definition of a full text index over some properties ## Source -[types.ts:131](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L131) +[types.ts:135](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L135) diff --git a/docs/type-aliases/GraphModelOptions.md b/docs/type-aliases/GraphModelOptions.md index ff1fae4..ddd71e9 100644 --- a/docs/type-aliases/GraphModelOptions.md +++ b/docs/type-aliases/GraphModelOptions.md @@ -48,4 +48,4 @@ Options to configure Open AI ## Source -[types.ts:197](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L197) +[types.ts:201](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L201) diff --git a/docs/type-aliases/GraphNodeProperties.md b/docs/type-aliases/GraphNodeProperties.md index ca0c8ee..a76d6cb 100644 --- a/docs/type-aliases/GraphNodeProperties.md +++ b/docs/type-aliases/GraphNodeProperties.md @@ -12,4 +12,4 @@ The properties allowed on graph nodes ## Source -[types.ts:170](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L170) +[types.ts:174](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L174) diff --git a/docs/type-aliases/Logger.md b/docs/type-aliases/Logger.md index d9bcb9e..cda9c69 100644 --- a/docs/type-aliases/Logger.md +++ b/docs/type-aliases/Logger.md @@ -89,4 +89,4 @@ Function signature for a logger ## Source -[types.ts:181](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L181) +[types.ts:185](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L185) diff --git a/docs/type-aliases/OpenAiOptions.md b/docs/type-aliases/OpenAiOptions.md index 2143db7..3440674 100644 --- a/docs/type-aliases/OpenAiOptions.md +++ b/docs/type-aliases/OpenAiOptions.md @@ -44,4 +44,4 @@ Tool choice ## Source -[types.ts:54](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L54) +[types.ts:54](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L54) diff --git a/docs/type-aliases/PropertyBag.md b/docs/type-aliases/PropertyBag.md index 3695634..5d7875a 100644 --- a/docs/type-aliases/PropertyBag.md +++ b/docs/type-aliases/PropertyBag.md @@ -12,4 +12,4 @@ A untyped set of properties ## Source -[types.ts:165](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L165) +[types.ts:169](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L169) diff --git a/docs/type-aliases/SimilarityResult.md b/docs/type-aliases/SimilarityResult.md index aeb9db7..ad02e15 100644 --- a/docs/type-aliases/SimilarityResult.md +++ b/docs/type-aliases/SimilarityResult.md @@ -26,4 +26,4 @@ Result of a vector similarity search ## Source -[types.ts:156](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L156) +[types.ts:160](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L160) diff --git a/docs/type-aliases/TextToGraphOptions.md b/docs/type-aliases/TextToGraphOptions.md index b6a9adc..6c72f2b 100644 --- a/docs/type-aliases/TextToGraphOptions.md +++ b/docs/type-aliases/TextToGraphOptions.md @@ -32,4 +32,4 @@ An optional prompt to further guide conversion of text to graph ## Source -[types.ts:111](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L111) +[types.ts:115](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L115) diff --git a/docs/type-aliases/ToolMessage.md b/docs/type-aliases/ToolMessage.md index 07de891..972c049 100644 --- a/docs/type-aliases/ToolMessage.md +++ b/docs/type-aliases/ToolMessage.md @@ -20,4 +20,4 @@ ## Source -[types.ts:211](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L211) +[types.ts:215](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L215) diff --git a/docs/type-aliases/ToolOptions.md b/docs/type-aliases/ToolOptions.md index 1b21e0d..fc585f3 100644 --- a/docs/type-aliases/ToolOptions.md +++ b/docs/type-aliases/ToolOptions.md @@ -44,4 +44,4 @@ Creates tools to retrieve nodes via similarity search of vector indexed properti ## Source -[types.ts:28](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L28) +[types.ts:28](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L28) diff --git a/docs/type-aliases/ToolResponse.md b/docs/type-aliases/ToolResponse.md index 44aa170..e5796ca 100644 --- a/docs/type-aliases/ToolResponse.md +++ b/docs/type-aliases/ToolResponse.md @@ -26,4 +26,4 @@ The string that we should compute embedding vectors for ## Source -[types.ts:219](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L219) +[types.ts:223](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L223) diff --git a/docs/type-aliases/VectorIndex.md b/docs/type-aliases/VectorIndex.md index d832536..cbd2008 100644 --- a/docs/type-aliases/VectorIndex.md +++ b/docs/type-aliases/VectorIndex.md @@ -38,4 +38,4 @@ Definition of a vector (embeddings) index ## Source -[types.ts:16](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L16) +[types.ts:16](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L16) diff --git a/docs/variables/ConsoleLogger.md b/docs/variables/ConsoleLogger.md index 8de0044..a33f040 100644 --- a/docs/variables/ConsoleLogger.md +++ b/docs/variables/ConsoleLogger.md @@ -10,4 +10,4 @@ ## Source -[ConsoleLogger.ts:10](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/ConsoleLogger.ts#L10) +[ConsoleLogger.ts:10](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/ConsoleLogger.ts#L10) diff --git a/docs/variables/EMBEDDINGS_MAGIC.md b/docs/variables/EMBEDDINGS_MAGIC.md index 3432ef1..cd78961 100644 --- a/docs/variables/EMBEDDINGS_MAGIC.md +++ b/docs/variables/EMBEDDINGS_MAGIC.md @@ -14,4 +14,4 @@ that include semantic embeddings ## Source -[types.ts:11](https://github.com/accordproject/lab-concerto-graph/blob/87c81018347fa08584f3cb9907a3e77815e8c62a/src/types.ts#L11) +[types.ts:11](https://github.com/accordproject/lab-concerto-graph/blob/7906621d6d0601d49217ffdd5ad64cfc20af0507/src/types.ts#L11) diff --git a/src/Conversation.ts b/src/Conversation.ts index b246a5b..91941b8 100644 --- a/src/Conversation.ts +++ b/src/Conversation.ts @@ -65,10 +65,10 @@ export class Conversation { * The system message * @returns the system message for the conversation */ - getSystemMessage(prompt?:string) { + getSystemMessage() { return { role: 'system', - content: prompt ? prompt : CONVERSATION_PROMPT, + content: this.options.systemPrompt ? this.options.systemPrompt : CONVERSATION_PROMPT, }; } diff --git a/src/TextToGraph.ts b/src/TextToGraph.ts index 8464064..e942da9 100644 --- a/src/TextToGraph.ts +++ b/src/TextToGraph.ts @@ -23,7 +23,8 @@ export class TextToGraph { mergeNodesAndRelatioships: true }, logger: options.logger, - openAiOptions: options.openAiOptions + openAiOptions: options.openAiOptions, + systemPrompt: options.textToGraphPrompt, }); } @@ -33,8 +34,7 @@ export class TextToGraph { * @returns an object that describes which nodes and relationships were added */ async mergeText(text: string) { - const prompt = this.options.textToGraphPrompt ? this.options.textToGraphPrompt : TEXT_TO_GRAPH_PROMPT; - const messages:Array = await this.conversation.runMessages([this.conversation.getSystemMessage(prompt)], `Add the nodes in this text to the knowledge graph: ${text}`); + const messages:Array = await this.conversation.runMessages([this.conversation.getSystemMessage()], `Add the nodes in this text to the knowledge graph: ${text}`); const relationships:Array = []; const nodes:Array = []; for(let n=0; n < messages.length; n++) { diff --git a/src/prompt.ts b/src/prompt.ts index c180801..3ba8024 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -2,29 +2,6 @@ import { ChatCompletionSystemMessageParam } from "openai/resources"; import { EMBEDDINGS_MAGIC } from "./types"; import { RunnableToolFunction } from "openai/lib/RunnableFunction"; -export function getTextToGraphPrompt(textToGraphPrompt:string, ctoModel:string, text:string) : ChatCompletionSystemMessageParam { - return { - role: 'system', - content: `You are an expert assistant that converts natural language text into a knowlege graph. - -${textToGraphPrompt} - -A knowledge graph is composed of nodes, with relationships between the nodes. Nodes have a label and a set of properties. -The structure of the nodes and relationships that you output must conform to a schema defined by an Accord Project Concerto model. -Here is the Concerto model you must use: - -\`\`\` -${ctoModel} -\`\`\` - -To create a node you output a JSON object of the form: {"type" : "node", "label" : "Person", "properties" : } where PROPS are the properties of the Person node. -To create a relationship you output a JSON object of the form: {"type" : "relationship", "startNodeLabel" : "Actor", "startNodeIdentifier" : "Johnny Depp", "endNodeLabel": "Movie", "endNodeIdentifier" : "Fear and Loathing in Las Vegas", "startNodePropertyName" : "actedIn" }. - -Convert the following natural language to a JSON object with an 'elements' property that is an array of nodes and relationships: """${text} -""" -`} -} - export function getTextToCypherPrompt(ctoModel:string, text:string) : ChatCompletionSystemMessageParam { return { role: 'system', @@ -83,8 +60,6 @@ export const TEXT_TO_GRAPH_PROMPT = 'Please create nodes and relationships in ou export const OPENAI_MODEL = 'gpt-4o'; export const TOOL_GET_EMBEDDINGS_NAME = "get_embeddings"; -export const TOOL_CREATE_NODE_NAME = "create_graph_node"; -export const TOOL_CREATE_EDGE_NAME = "create_graph_edge"; /** * This defines an OpenAI tool that can be used diff --git a/src/types.ts b/src/types.ts index d569d2b..7bd039d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -103,6 +103,10 @@ export type ConversationOptions = { * Options to configure Open AI */ openAiOptions?: OpenAiOptions + /** + * System prompt + */ + systemPrompt?: string; } /**