code: from llama_index import SimpleDirectoryReader 
  from llama_index import ServiceContext
  from langchain.chat_models import ChatOpenAI
  from llama_index import VectorStoreIndex
  from utils import build_sentence_window_index
  from utils import build_automerging_index
  
  
  import sys
  import os
  import logging
  import configparser
  
  config = configparser.ConfigParser()
  config.read('config.ini')
  
  
  
  # get config values
  src_data_dir = config['index']['src_data_dir']
  basic_idx_dir = config['index']['basic_idx_dir']
  sent_win_idx_dir = config['index']['sent_win_idx_dir']
  auto_mrg_idx_dir = config['index']['auto_mrg_idx_dir']
  modelname = config['index']['modelname']
  embed_modelname = config['index']['embedmodel']
  
          
  def check_and_create_directory(directory_path):
      if not os.path.exists(directory_path):
          os.makedirs(directory_path)
          print(f"Directory '{directory_path}' created successfully.")
      else:
          print(f"Directory '{directory_path}' already exists.")
          
  def construct_basic_index(src_directory_path,index_directory):        
      check_and_create_directory(index_directory)     
      llm =ChatOpenAI(temperature=0.1, model_name=modelname)
      service_context = ServiceContext.from_defaults(
          llm=llm, embed_model=embed_modelname
      )
     
      documents = SimpleDirectoryReader(src_directory_path).load_data()
      index = VectorStoreIndex.from_documents(documents,
                                              service_context=service_context)
        
      index.storage_context.persist(persist_dir=index_directory)     
      return index
  
  def construct_sentencewindow_index(src_directory_path,index_directory):    
      
      llm =ChatOpenAI(temperature=0.1, model_name=modelname)
      documents = SimpleDirectoryReader(src_directory_path).load_data()
      index = build_sentence_window_index(
      documents,
      llm,
      embed_model=embed_modelname,
      save_dir=index_directory
      )
      return index
  
  def construct_automerge_index(src_directory_path,index_directory):    
      llm =ChatOpenAI(temperature=0.1, model_name=modelname)
      documents = SimpleDirectoryReader(src_directory_path).load_data()
      index = build_automerging_index(
      documents,
      llm,
      embed_model=embed_modelname,
      save_dir=index_directory
      )
      return index
   
      
  logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
  logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
   
   
  #Create basic index
  index = construct_basic_index(src_data_dir,basic_idx_dir)
  #create sentencewindow index
  sentindex = construct_sentencewindow_index(src_data_dir,sent_win_idx_dir)
  #create automerge index
  autoindex = construct_automerge_index(src_data_dir,auto_mrg_idx_dir)
apis: llama_index.VectorStoreIndex.from_documents llama_index.ServiceContext.from_defaults llama_index.SimpleDirectoryReader
extract_api: [((328, 355), 'configparser.ConfigParser', 'configparser.ConfigParser', ([], {}), '()\n', (353, 355), False, 'import configparser\n'), ((2287, 2346), 'logging.basicConfig', 'logging.basicConfig', ([], {'stream': 'sys.stdout', 'level': 'logging.DEBUG'}), '(stream=sys.stdout, level=logging.DEBUG)\n', (2306, 2346), False, 'import logging\n'), ((1121, 1170), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'temperature': '(0.1)', 'model_name': 'modelname'}), '(temperature=0.1, model_name=modelname)\n', (1131, 1170), False, 'from langchain.chat_models import ChatOpenAI\n'), ((1193, 1259), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm': 'llm', 'embed_model': 'embed_modelname'}), '(llm=llm, embed_model=embed_modelname)\n', (1221, 1259), False, 'from llama_index import ServiceContext\n'), ((1360, 1435), 'llama_index.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['documents'], {'service_context': 'service_context'}), '(documents, service_context=service_context)\n', (1391, 1435), False, 'from llama_index import VectorStoreIndex\n'), ((1663, 1712), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'temperature': '(0.1)', 'model_name': 'modelname'}), '(temperature=0.1, model_name=modelname)\n', (1673, 1712), False, 'from langchain.chat_models import ChatOpenAI\n'), ((1795, 1897), 'utils.build_sentence_window_index', 'build_sentence_window_index', (['documents', 'llm'], {'embed_model': 'embed_modelname', 'save_dir': 'index_directory'}), '(documents, llm, embed_model=embed_modelname,\n    save_dir=index_directory)\n', (1822, 1897), False, 'from utils import build_sentence_window_index\n'), ((2014, 2063), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'temperature': '(0.1)', 'model_name': 'modelname'}), '(temperature=0.1, model_name=modelname)\n', (2024, 2063), False, 'from langchain.chat_models import ChatOpenAI\n'), ((2146, 2244), 'utils.build_automerging_index', 'build_automerging_index', (['documents', 'llm'], {'embed_model': 'embed_modelname', 'save_dir': 'index_directory'}), '(documents, llm, embed_model=embed_modelname,\n    save_dir=index_directory)\n', (2169, 2244), False, 'from utils import build_automerging_index\n'), ((2378, 2418), 'logging.StreamHandler', 'logging.StreamHandler', ([], {'stream': 'sys.stdout'}), '(stream=sys.stdout)\n', (2399, 2418), False, 'import logging\n'), ((769, 799), 'os.path.exists', 'os.path.exists', (['directory_path'], {}), '(directory_path)\n', (783, 799), False, 'import os\n'), ((809, 836), 'os.makedirs', 'os.makedirs', (['directory_path'], {}), '(directory_path)\n', (820, 836), False, 'import os\n'), ((2347, 2366), 'logging.getLogger', 'logging.getLogger', ([], {}), '()\n', (2364, 2366), False, 'import logging\n'), ((1294, 1335), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['src_directory_path'], {}), '(src_directory_path)\n', (1315, 1335), False, 'from llama_index import SimpleDirectoryReader\n'), ((1729, 1770), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['src_directory_path'], {}), '(src_directory_path)\n', (1750, 1770), False, 'from llama_index import SimpleDirectoryReader\n'), ((2080, 2121), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['src_directory_path'], {}), '(src_directory_path)\n', (2101, 2121), False, 'from llama_index import SimpleDirectoryReader\n')]