docstore = SimpleDocumentStore()
docstore.add_documents(documents)
vector_store = MilvusVectorStore(**config.get("vector_store"))
index_store = SimpleIndexStore()
storage_context = StorageContext.from_defaults(vector_store=vector_store,
index_store=index_store,
docstore=docstore)
embed_model = OpenAIEmbedding() if os.environ.get("OPENAI_API_KEY") else "local"
service_context = ServiceContext.from_defaults(embed_model=embed_model)
index = VectorStoreIndex.from_documents(documents=documents,
storage_context=storage_context,
service_context=service_context,
show_progress=True)
index.storage_context.persist(config.get("storage_context"))
docstore.persist(config.get("documents_store"))