----------------------
To use Neo4j with LlamaIndex, you need to follow these steps:
- Install LlamaIndex. If you're using a Jupyter notebook, you can install it using pip:
- Set your OpenAI API key:
import os
import openai
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY_HERE"
openai.api_key = os.environ["OPENAI_API_KEY"]
- Initiate the Neo4j vector wrapper:
from llama_index.vector_stores import Neo4jVectorStore
username = "neo4j"
password = "pleaseletmein"
url = "bolt://localhost:7687"
embed_dim = 1536
neo4j_vector = Neo4jVectorStore(username, password, url, embed_dim)
- Load your documents and build the VectorStoreIndex:
from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.storage.storage_context import StorageContext
# load documents
documents = SimpleDirectoryReader("./data/paul_graham").load_data()
# create storage context
storage_context = StorageContext.from_defaults(vector_store=neo4j_vector)
# create index
index = VectorStoreIndex.from_documents(documents, storage_context=storage_context)
- Query the index:
query_engine = index.as_query_engine()
response = query_engine.query("Your query here")
Please replace
"Your query here"
with your actual query.
For more details, you can refer to the
Neo4j vector store example () on the LlamaIndex GitHub page.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------