@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)
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()