code: import os
  from llama_index import LLMPredictor, VectorStoreIndex, SimpleDirectoryReader, ServiceContext, LangchainEmbedding
  from langchain.embeddings import OpenAIEmbeddings
  from langchain.llms import AzureOpenAI
  import openai
  import logging
  import sys
  
  #llamaindex logs
  logging.basicConfig(stream=sys.stdout, level=logging.INFO) # logging.DEBUG for more verbose output
  logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
  
  #Enable to show openai logs
  #openai.log='debug'
  
  #Based on your settings, see version, base, key in your Azure AI portal
  api_type = "azure"
  api_version = "2023-03-15-preview"
  api_base = os.getenv("AZURE_API_BASE")
  api_key = os.getenv("AZURE_API_KEY")
  chat_deployment = "gpt35"
  embedding_deployment= "text-embedding-ada-002"
  
  # Chat model
  llm = AzureOpenAI(deployment_name=chat_deployment, openai_api_base=api_base, openai_api_key=api_key, model_kwargs={
      "api_type": api_type,
      "api_version": api_version,
  })
  llm_predictor = LLMPredictor(llm=llm)
  
  # Embedding model
  embedding_llm = LangchainEmbedding(
      OpenAIEmbeddings(
          model=embedding_deployment,
          deployment=embedding_deployment,
          openai_api_key=api_key,
          openai_api_base=api_base,
          openai_api_type=api_type,
          openai_api_version=api_version,
      ),
      embed_batch_size=1
  )
  
  #load docs
  documents = SimpleDirectoryReader('local-data').load_data()
  
  service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, embed_model=embedding_llm)
  
  index = VectorStoreIndex.from_documents(documents, service_context=service_context)
  
  index.storage_context.persist(persist_dir="local-index-azure")
  print("Saved embeddings")
  
apis: llama_index.VectorStoreIndex.from_documents llama_index.ServiceContext.from_defaults llama_index.LLMPredictor llama_index.SimpleDirectoryReader
extract_api: [((271, 329), 'logging.basicConfig', 'logging.basicConfig', ([], {'stream': 'sys.stdout', 'level': 'logging.INFO'}), '(stream=sys.stdout, level=logging.INFO)\n', (290, 329), False, 'import logging\n'), ((630, 657), 'os.getenv', 'os.getenv', (['"""AZURE_API_BASE"""'], {}), "('AZURE_API_BASE')\n", (639, 657), False, 'import os\n'), ((668, 694), 'os.getenv', 'os.getenv', (['"""AZURE_API_KEY"""'], {}), "('AZURE_API_KEY')\n", (677, 694), False, 'import os\n'), ((788, 955), 'langchain.llms.AzureOpenAI', 'AzureOpenAI', ([], {'deployment_name': 'chat_deployment', 'openai_api_base': 'api_base', 'openai_api_key': 'api_key', 'model_kwargs': "{'api_type': api_type, 'api_version': api_version}"}), "(deployment_name=chat_deployment, openai_api_base=api_base,\n    openai_api_key=api_key, model_kwargs={'api_type': api_type,\n    'api_version': api_version})\n", (799, 955), False, 'from langchain.llms import AzureOpenAI\n'), ((975, 996), 'llama_index.LLMPredictor', 'LLMPredictor', ([], {'llm': 'llm'}), '(llm=llm)\n', (987, 996), False, 'from llama_index import LLMPredictor, VectorStoreIndex, SimpleDirectoryReader, ServiceContext, LangchainEmbedding\n'), ((1414, 1503), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm_predictor': 'llm_predictor', 'embed_model': 'embedding_llm'}), '(llm_predictor=llm_predictor, embed_model=\n    embedding_llm)\n', (1442, 1503), False, 'from llama_index import LLMPredictor, VectorStoreIndex, SimpleDirectoryReader, ServiceContext, LangchainEmbedding\n'), ((1508, 1583), 'llama_index.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['documents'], {'service_context': 'service_context'}), '(documents, service_context=service_context)\n', (1539, 1583), False, 'from llama_index import LLMPredictor, VectorStoreIndex, SimpleDirectoryReader, ServiceContext, LangchainEmbedding\n'), ((401, 441), 'logging.StreamHandler', 'logging.StreamHandler', ([], {'stream': 'sys.stdout'}), '(stream=sys.stdout)\n', (422, 441), False, 'import logging\n'), ((1056, 1250), 'langchain.embeddings.OpenAIEmbeddings', 'OpenAIEmbeddings', ([], {'model': 'embedding_deployment', 'deployment': 'embedding_deployment', 'openai_api_key': 'api_key', 'openai_api_base': 'api_base', 'openai_api_type': 'api_type', 'openai_api_version': 'api_version'}), '(model=embedding_deployment, deployment=\n    embedding_deployment, openai_api_key=api_key, openai_api_base=api_base,\n    openai_api_type=api_type, openai_api_version=api_version)\n', (1072, 1250), False, 'from langchain.embeddings import OpenAIEmbeddings\n'), ((370, 389), 'logging.getLogger', 'logging.getLogger', ([], {}), '()\n', (387, 389), False, 'import logging\n'), ((1347, 1382), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""local-data"""'], {}), "('local-data')\n", (1368, 1382), False, 'from llama_index import LLMPredictor, VectorStoreIndex, SimpleDirectoryReader, ServiceContext, LangchainEmbedding\n')]