----------------------
Based on the error message you provided, it seems like you need to provide either
nodes
or
index_struct
when initializing
KnowledgeGraphIndex
. However, in the code snippet you provided, neither of these parameters is given.
From the information extracts, I can provide a code snippet that shows how to initialize
KnowledgeGraphIndex
using documents loaded from a directory. This might not be exactly what you need, but it could give you an idea of how to proceed.
Here is the code snippet:
from llama_index import (
KnowledgeGraphIndex,
ServiceContext,
SimpleDirectoryReader,
)
from llama_index.storage.storage_context import StorageContext
from llama_index.graph_stores import Neo4jGraphStore
# Load documents from a directory
documents = SimpleDirectoryReader(
"../../../../examples/paul_graham_essay/data"
).load_data()
# Define LLM
llm = OpenAI(temperature=0, model="gpt-3.5-turbo")
service_context = ServiceContext.from_defaults(llm=llm, chunk_size=512)
# Define graph store
graph_store = Neo4jGraphStore(
username="neo4j",
password="password",
url="bolt://localhost:7687",
database="neo4j",
)
storage_context = StorageContext.from_defaults(graph_store=graph_store)
# Instantiate KnowledgeGraphIndex
index = KnowledgeGraphIndex.from_documents(
documents,
storage_context=storage_context,
max_triplets_per_chunk=2,
service_context=service_context,
)
This code snippet is based on the information extracted from
here () and
here ().