Skip to content

Commit b57a279

Browse files
committed
fix: make OpenAI optional
Signed-off-by: Dan Selman <[email protected]>
1 parent 15002f0 commit b57a279

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ Runtime result:
6565

6666
### GraphDB
6767

68-
- NEO4J_URL: <optional> the NEO4J URL. If not set, no data will be written to the agreement graph.
69-
- NEO4J_PASS: <optional> the neo4j password.
68+
- NEO4J_URL: the NEO4J URL. E.g. `neo4j+s://<DB_NAME>.databases.neo4j.io` if you are using AuraDB.
69+
- NEO4J_PASS: your neo4j password.
70+
- NEO4J_USER: <optional> defaults to `neo4j`
7071

7172
### Text Embeddings
7273
- OPENAI_API_KEY: <optional> the OpenAI API key. If not set embeddings are not computed and written to the agreement graph and similarity search is not possible.

src/demo/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async function run() {
5555
NEO4J_URL: process.env.NEO4J_URL,
5656
logger: console,
5757
logQueries: false,
58-
embeddingFunction: getOpenAiEmbedding
58+
embeddingFunction: process.env.OPENAI_API_KEY ? getOpenAiEmbedding : undefined
5959
}
6060
const graphModel = new GraphModel(MODEL, options);
6161
await graphModel.connect();
@@ -100,9 +100,12 @@ async function run() {
100100
await graphModel.mergeNode(transaction, `${NS}.Actor`, {identifier: 'Johnny Depp'} );
101101
await graphModel.mergeRelationship(transaction, `${NS}.Actor`, 'Johnny Depp', `${NS}.Movie`, 'Fear and Loathing in Las Vegas', 'actedIn' );
102102
});
103-
const search = 'Working in a boring job and looking for love.';
104-
const results = await graphModel.similarityQuery(`${NS}.Movie`, 'embedding', search, 3);
105-
console.log(results);
103+
if(process.env.OPENAI_API_KEY) {
104+
const search = 'Working in a boring job and looking for love.';
105+
console.log(`Searching for movies related to: '${search}'`);
106+
const results = await graphModel.similarityQuery(`${NS}.Movie`, 'embedding', search, 3);
107+
console.log(results);
108+
}
106109
await graphModel.closeSession(context);
107110
console.log('done');
108111
}

0 commit comments

Comments
 (0)