Find answers from the community

Updated 4 months ago

Hi has anyone else come across this

At a glance
Hi has anyone else come across this error:
No existing llama_index.storage.kvstore.simple_kvstore found at ./index.json/docstore.json.

I am using from llama_index import StorageContext, load_index_from_storage modules?
j
g
3 comments
are you persisting to disk?
@jerryjliu0 Me too, I am going through this error 😦
I am persisting to disk.

// constructing index
documents = SimpleDirectoryReader(directory).load_data()
storage_context = StorageContext.from_defaults()
index = GPTVectorStoreIndex.from_documents(documents, storage_context=storage_context)
storage_context.persist(persist_dir=index_path)

// querying index
storage_context = StorageContext.from_defaults(persist_dir='download/{}/index.json'.format(hash_value))
index = load_index_from_storage(storage_context=storage_context)

Please help me with this!
For future developers, I solved this error.

It seems that you cannot set a fixed name to save to the disk (i.e. "index.json").
Here's the code that works:

// constructing index
check_index_path = os.path.join(directory, 'index_store.json')

if not os.path.exists(check_index_path):
with open(check_index_path, 'w', encoding='utf-8') as file:
print("DEBUG: index.json does not exist... creating it")
documents = SimpleDirectoryReader(directory).load_data()
index = GPTVectorStoreIndex.from_documents(documents)
index.storage_context.persist(persist_dir=directory)

// querying index
storage_context = StorageContext.from_defaults(persist_dir='download/{}'.format(hash_value))
index = load_index_from_storage(storage_context=storage_context)
query_engine = index.as_query_engine()

try:
response = query_engine.query(query)
Add a reply
Sign up and join the conversation on Discord