Find answers from the community

Updated last year

I am trying to rebuild storage context,

At a glance
I am trying to rebuild storage context, but its constantly giving me a KeyError: 'default'

Here's my code to rebuild the index
Plain Text
from llama_index import StorageContext, load_index_from_storage

# rebuild storage context
storage_context = StorageContext.from_defaults(persist_dir="./check_storage")
# load index
index = load_index_from_storage(storage_context)


And, here's how I'm storing it

Plain Text
# Create a local Qdrant vector store
client = qdrant_client.QdrantClient(path="play_qdrant_gemini")
vector_store = QdrantVectorStore(client=client, collection_name="collection")

embed_model = LangchainEmbedding(HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2"))
service_context = ServiceContext.from_defaults(embed_model=embed_model)
storage_context = StorageContext.from_defaults(vector_store=vector_store)

nodes = [TextNode(text="HelloWorld"), TextNode(text="HelloWorld")]

index = VectorStoreIndex(
    nodes=nodes,
    storage_context=storage_context,
    service_context=service_context,
)

index.storage_context.persist(persist_dir='./check_storage')


Any suggestions ?
c
w
5 comments
Here's the full error message
Attachment
image.png
I don't remember if I had exactly the same issue, but adding the service context when loading the index helped me. (so load_index_from_storage(storage_context, service_context = service_context)
Tried this. Didn't work 😒
I just checked the storage folder and realised that the index isn't storing anything in the first place
Maybe because I am using a QdrantVectorStore and the regular way doesnt't work to save or retrieve this kinda thing
Add a reply
Sign up and join the conversation on Discord