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 import GPTVectorStoreIndex,VectorStoreIndex, StorageContext, SimpleDirectoryReader, ServiceContext
  from llama_index.vector_stores import MilvusVectorStore
  from llama_index.embeddings import HuggingFaceEmbedding
  
  import torch
  
  from llama_index.llms import HuggingFaceLLM
  from llama_index.prompts import PromptTemplate
  
  
  
  vector_store = MilvusVectorStore(
      uri = "http://localhost:19530",
      port = 19530   ,
      collection_name = 'llama_index_prompts_all',
      dim = 384,
      similarity_metric = "L2",
  )
  
  
  sample_files_path = "E:\prompt_sources\lexica_split"
  
  embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-MiniLM-L12-v2")
  
  storage_context = StorageContext.from_defaults(vector_store=vector_store)
  
  service_context = ServiceContext.from_defaults(llm=None, embed_model=embed_model)
  
  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()
  
          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, service_context=service_context, show_progress=True)
  
  
apis: llama_index.VectorStoreIndex.from_documents llama_index.ServiceContext.from_defaults llama_index.StorageContext.from_defaults llama_index.SimpleDirectoryReader llama_index.embeddings.HuggingFaceEmbedding llama_index.vector_stores.MilvusVectorStore
extract_api: [((946, 1086), 'llama_index.vector_stores.MilvusVectorStore', 'MilvusVectorStore', ([], {'uri': '"""http://localhost:19530"""', 'port': '(19530)', 'collection_name': '"""llama_index_prompts_all"""', 'dim': '(384)', 'similarity_metric': '"""L2"""'}), "(uri='http://localhost:19530', port=19530, collection_name\n    ='llama_index_prompts_all', dim=384, similarity_metric='L2')\n", (963, 1086), False, 'from llama_index.vector_stores import MilvusVectorStore\n'), ((1188, 1262), 'llama_index.embeddings.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': '"""sentence-transformers/all-MiniLM-L12-v2"""'}), "(model_name='sentence-transformers/all-MiniLM-L12-v2')\n", (1208, 1262), False, 'from llama_index.embeddings import HuggingFaceEmbedding\n'), ((1282, 1337), 'llama_index.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'vector_store': 'vector_store'}), '(vector_store=vector_store)\n', (1310, 1337), False, 'from llama_index import GPTVectorStoreIndex, VectorStoreIndex, StorageContext, SimpleDirectoryReader, ServiceContext\n'), ((1357, 1420), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm': 'None', 'embed_model': 'embed_model'}), '(llm=None, embed_model=embed_model)\n', (1385, 1420), False, 'from llama_index import GPTVectorStoreIndex, VectorStoreIndex, StorageContext, SimpleDirectoryReader, ServiceContext\n'), ((1449, 1475), 'os.walk', 'os.walk', (['sample_files_path'], {}), '(sample_files_path)\n', (1456, 1475), False, 'import os\n'), ((1514, 1537), 'datetime.datetime.now', 'datetime.datetime.now', ([], {}), '()\n', (1535, 1537), False, 'import datetime\n'), ((1961, 2088), 'llama_index.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['docs'], {'storage_context': 'storage_context', 'service_context': 'service_context', 'show_progress': '(True)'}), '(docs, storage_context=storage_context,\n    service_context=service_context, show_progress=True)\n', (1992, 2088), False, 'from llama_index import GPTVectorStoreIndex, VectorStoreIndex, StorageContext, SimpleDirectoryReader, ServiceContext\n'), ((1628, 1657), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['subdir'], {}), '(subdir)\n', (1649, 1657), False, 'from llama_index import GPTVectorStoreIndex, VectorStoreIndex, StorageContext, SimpleDirectoryReader, ServiceContext\n')]