Reputation: 73
index.storage_context.persist()
is not storing the vector_store and creating thevector_store.json
file
When I try to load from disk and run sc2 = StorageContext.from_defaults(persist_dir='./storage')
, i get the following error:
No existing llama_index.vector_stores.simple found at ./storage/vector_store.json, skipping load.
Not sure if this information is relevant, but there is only 1 document in my documents directory for embedding
Full Code:
with open('KPMGOutlook/kpmgoutlook.text', 'w') as file: file.write(kpmg_text)
documents = SimpleDirectoryReader('KPMGOutlook').load_data()
vector_store = ChromaVectorStore(chroma_collection) storage_context = StorageContext.from_defaults(vector_store=vector_store,persist_dir='storage')
index = GPTVectorStoreIndex.from_documents(documents, storage_context=storage_context)
index.storage_context.persist()
query_engine = index.as_query_engine()
#Querying document. this works fine r = query_engine.query("Which economy has the most positive outlook?") print(r)
#This line gives me the error
sc2 = StorageContext.from_defaults(persist_dir='./storage')
Upvotes: 3
Views: 3667
Reputation: 11
Check this LlamaIndex documentation
It says that you have to give a reference to your ServiceContext object if you had initialized your index with a custom ServiceContext object.
Hope this solves your issue.
Upvotes: 0