In this lesson, you will learn how to create a vector index on existing data.
-
Create an Embeddings model instance
-
Create a Vector Store on all
Talknodes using thetitleanddescriptionproperties. Save the embedding to theembeddingproperty -
Grab a coffee and wait… ☕️
Solution
typescript
import { Neo4jVectorStore } from "@langchain/community/vectorstores/neo4j_vector";
import { OpenAIEmbeddings } from "@langchain/openai";
import { config } from "dotenv";
async function main() {
config({ path: "./.env.local" });
const embeddings = new OpenAIEmbeddings({
openAIApiKey: process.env.OPEN_AI_API_KEY,
});
const store = await Neo4jVectorStore.fromExistingGraph(embeddings, {
url: process.env.NEO4J_URI,
username: process.env.NEO4J_USERNAME,
password: process.env.NEO4J_PASSWORD,
nodeLabel: "Talk",
textNodeProperties: ["title", "description"],
indexName: "talk_embeddings_openai",
embeddingNodeProperty: "embedding",
});
await store.close();
}
main();Verify Challenge
Verifying the Test
Once you have executed the code, click the Verify button and we will check that the code has been executed successfully.
Summary
Well done!
Summary
This lesson covers important concepts and techniques.