Find answers from the community

Updated last year

how to use Neo4j with llamaindex?

At a glance
@kapa.ai how to use Neo4j with llamaindex?
k
a
5 comments
Please stand by @andysingal as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
To use Neo4j with LlamaIndex, you need to follow these steps:

  1. Install LlamaIndex. If you're using a Jupyter notebook, you can install it using pip:
Plain Text
!pip install llama-index

  1. Set your OpenAI API key:
Plain Text
import os
import openai

os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY_HERE"
openai.api_key = os.environ["OPENAI_API_KEY"]

  1. Initiate the Neo4j vector wrapper:
Plain Text
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)

  1. Load your documents and build the VectorStoreIndex:
Plain Text
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)

  1. Query the index:
Plain Text
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:
----------------------
@kapa.ai how to use Neo4j with RAG?
Let me check the knowledge base for you. One moment! :books:
----------------------
Hmm, I don't know enough to give you a confident answer yet. The provided extracts do not contain specific information on how to use Neo4j with Retrieval-Augmented Generation (RAG) in the context of LlamaIndex.

For more detailed information, you may want to refer to the LlamaIndex documentation () or the LlamaIndex GitHub page ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord