code: # Copyright 2023 osiworx
  
  # Licensed under the Apache License, Version 2.0 (the "License"); you
  # may not use this file except in compliance with the License.  You
  # may obtain a copy of the License at
  
  # http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  # implied.  See the License for the specific language governing
  # permissions and limitations under the License.
  
  import datetime
  import os
  
  
  from llama_index.vector_stores.milvus import MilvusVectorStore
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
  
  
  from llama_index.core import (
      VectorStoreIndex,
      SimpleDirectoryReader,
  )
  from llama_index.core.storage.storage_context import StorageContext
  
  vector_store = MilvusVectorStore(
      uri = "http://localhost:19530",
      port = 19530   ,
      collection_name = 'llama_index_prompts_large',
      dim = 384,
      similarity_metric = "L2",
  
  )
  
  sample_files_path = "E:\short_large"
  
  embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-MiniLM-L12-v2")
  
  storage_context = StorageContext.from_defaults(vector_store=vector_store)
  
  
  for subdir, dirs, files in os.walk(sample_files_path):
      if len(files) > 0:
          now = datetime.datetime.now()
          print(f'{now.strftime("%H:%M:%S")} adding folder: {subdir}')
  
          documents = SimpleDirectoryReader(subdir).load_data()
  
  
          # here we set the file_path to become no part of the embedding, its not for this usecase
          # also we check if a doc has zero content then we don't try to embedd it as it would result in an error
          docs = []
          for doc in documents:
              doc.excluded_llm_metadata_keys.append("file_path")
              doc.excluded_embed_metadata_keys.append("file_path")
              if doc.text != '':
                  docs = docs + [doc]
  
          del documents
  
          vector_index = VectorStoreIndex.from_documents(docs, storage_context=storage_context,embed_model=embed_model, show_progress=True)
  
  
  
apis: llama_index.embeddings.huggingface.HuggingFaceEmbedding llama_index.vector_stores.milvus.MilvusVectorStore llama_index.core.VectorStoreIndex.from_documents llama_index.core.SimpleDirectoryReader llama_index.core.storage.storage_context.StorageContext.from_defaults
extract_api: [((894, 1036), 'llama_index.vector_stores.milvus.MilvusVectorStore', 'MilvusVectorStore', ([], {'uri': '"""http://localhost:19530"""', 'port': '(19530)', 'collection_name': '"""llama_index_prompts_large"""', 'dim': '(384)', 'similarity_metric': '"""L2"""'}), "(uri='http://localhost:19530', port=19530, collection_name\n    ='llama_index_prompts_large', dim=384, similarity_metric='L2')\n", (911, 1036), False, 'from llama_index.vector_stores.milvus import MilvusVectorStore\n'), ((1122, 1196), 'llama_index.embeddings.huggingface.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': '"""sentence-transformers/all-MiniLM-L12-v2"""'}), "(model_name='sentence-transformers/all-MiniLM-L12-v2')\n", (1142, 1196), False, 'from llama_index.embeddings.huggingface import HuggingFaceEmbedding\n'), ((1216, 1271), 'llama_index.core.storage.storage_context.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'vector_store': 'vector_store'}), '(vector_store=vector_store)\n', (1244, 1271), False, 'from llama_index.core.storage.storage_context import StorageContext\n'), ((1301, 1327), 'os.walk', 'os.walk', (['sample_files_path'], {}), '(sample_files_path)\n', (1308, 1327), False, 'import os\n'), ((1366, 1389), 'datetime.datetime.now', 'datetime.datetime.now', ([], {}), '()\n', (1387, 1389), False, 'import datetime\n'), ((2023, 2142), 'llama_index.core.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['docs'], {'storage_context': 'storage_context', 'embed_model': 'embed_model', 'show_progress': '(True)'}), '(docs, storage_context=storage_context,\n    embed_model=embed_model, show_progress=True)\n', (2054, 2142), False, 'from llama_index.core import VectorStoreIndex, SimpleDirectoryReader\n'), ((1480, 1509), 'llama_index.core.SimpleDirectoryReader', 'SimpleDirectoryReader', (['subdir'], {}), '(subdir)\n', (1501, 1509), False, 'from llama_index.core import VectorStoreIndex, SimpleDirectoryReader\n')]