Skip to content

Loading VectorStoreIndex from StorageContext #18154

Closed Answered by dosubot bot
Alnasser0 asked this question in Q&A
Discussion options

You must be logged in to vote

To check if data is persisted on your disk and create a vector index only if the data is missing using DeepLakeVectorStore and VectorStoreIndex, you can use the following code:

from llama_index.core import VectorStoreIndex, StorageContext
from llama_index.vector_stores.deeplake import DeepLakeVectorStore
import os

# Define the dataset path
dataset_path = "<dataset_path>"

# Check if the dataset path exists
if not os.path.exists(dataset_path):
    # If the dataset does not exist, create a new vector store and index
    vector_store = DeepLakeVectorStore(dataset_path=dataset_path)
    storage_context = StorageContext.from_defaults(vector_store=vector_store)
    
    # Load documents and b…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Alnasser0
Comment options

@dosubot
Comment options

Answer selected by Alnasser0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant