Skip to content

index.storage_context.persist() not working as expected #10

@emilio-fiallos

Description

@emilio-fiallos

index.storage_context.persist() is not storing the vector_store and creating thevector_store.json file

image

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.

I only have 1 document in my documents directory... Your example had 2. I wonder if that has soemthing to do with the issue?
image

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions