code: from llama_index import SimpleDirectoryReader, LLMPredictor, ServiceContext, GPTVectorStoreIndex
  from langchain.chat_models import ChatOpenAI
  from dotenv import load_dotenv
  import os
  import graphsignal
  import logging
  import time
  import random
  
  load_dotenv()
  
  logging.basicConfig()
  logger = logging.getLogger()
  logger.setLevel(logging.DEBUG)
  
  graphsignal.configure(api_key=os.getenv('GRAPHSIGNAL_API_KEY'), deployment='DevSecOpsKB')
  
  # set context window
  context_window = 4096
  # set number of output tokens
  num_output = 512
  
  #LLMPredictor is a wrapper class around LangChain's LLMChain that allows easy integration into LlamaIndex
  llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.5, model_name="gpt-3.5-turbo", max_tokens=num_output))
  
  #constructs service_context
  service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, context_window=context_window, num_output=num_output)
  
  #set the global service context object
  from llama_index import set_global_service_context
  set_global_service_context(service_context)
  
  #loads data from the specified directory path
  documents = SimpleDirectoryReader("./data").load_data()
  
  #when first building the index
  index = GPTVectorStoreIndex.from_documents(documents)
  
  def data_querying(input_text):
      
      #queries the index with the input text
      response = index.as_query_engine().query(input_text)
      
      return response.response
      
  
  # predefine a list of 10 questions
  questions = [
      'what does Trivy image scan do?',
      'What are the main benefits of using Harden Runner?',
      'What is the 3-2-1 rule in DevOps self-service model?',
      'What is Infracost?  and what does it do?',
      'What is the terraform command to auto generate README?',
      'How to pin Terraform module source to a particular branch?',
      'What are the benefits of reusable Terraform modules?',
      'How do I resolve error "npm ERR! code E400"?',
      'How to fix error "NoCredentialProviders: no valid providers in chain"?',
      'How to fix error "Credentials could not be loaded, please check your action inputs: Could not load credentials from any providers"?'
  ]
  
  start_time = time.time()
  
  while time.time() - start_time < 1800:  # let it run for 30 minutes (1800 seconds)
      try:
          num = random.randint(0, len(questions) - 1)
          print("Question: ", questions[num])
          answer = data_querying(questions[num])
          print("Answer: ", answer)
      except:
          logger.error("Error during data query", exc_info=True)
  
      time.sleep(5 * random.random())
      
      
  
apis: llama_index.set_global_service_context llama_index.GPTVectorStoreIndex.from_documents llama_index.ServiceContext.from_defaults llama_index.SimpleDirectoryReader
extract_api: [((244, 257), 'dotenv.load_dotenv', 'load_dotenv', ([], {}), '()\n', (255, 257), False, 'from dotenv import load_dotenv\n'), ((259, 280), 'logging.basicConfig', 'logging.basicConfig', ([], {}), '()\n', (278, 280), False, 'import logging\n'), ((290, 309), 'logging.getLogger', 'logging.getLogger', ([], {}), '()\n', (307, 309), False, 'import logging\n'), ((790, 906), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm_predictor': 'llm_predictor', 'context_window': 'context_window', 'num_output': 'num_output'}), '(llm_predictor=llm_predictor, context_window=\n    context_window, num_output=num_output)\n', (818, 906), False, 'from llama_index import SimpleDirectoryReader, LLMPredictor, ServiceContext, GPTVectorStoreIndex\n'), ((993, 1036), 'llama_index.set_global_service_context', 'set_global_service_context', (['service_context'], {}), '(service_context)\n', (1019, 1036), False, 'from llama_index import set_global_service_context\n'), ((1180, 1225), 'llama_index.GPTVectorStoreIndex.from_documents', 'GPTVectorStoreIndex.from_documents', (['documents'], {}), '(documents)\n', (1214, 1225), False, 'from llama_index import SimpleDirectoryReader, LLMPredictor, ServiceContext, GPTVectorStoreIndex\n'), ((2128, 2139), 'time.time', 'time.time', ([], {}), '()\n', (2137, 2139), False, 'import time\n'), ((372, 404), 'os.getenv', 'os.getenv', (['"""GRAPHSIGNAL_API_KEY"""'], {}), "('GRAPHSIGNAL_API_KEY')\n", (381, 404), False, 'import os\n'), ((663, 741), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'temperature': '(0.5)', 'model_name': '"""gpt-3.5-turbo"""', 'max_tokens': 'num_output'}), "(temperature=0.5, model_name='gpt-3.5-turbo', max_tokens=num_output)\n", (673, 741), False, 'from langchain.chat_models import ChatOpenAI\n'), ((1096, 1127), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""./data"""'], {}), "('./data')\n", (1117, 1127), False, 'from llama_index import SimpleDirectoryReader, LLMPredictor, ServiceContext, GPTVectorStoreIndex\n'), ((2147, 2158), 'time.time', 'time.time', ([], {}), '()\n', (2156, 2158), False, 'import time\n'), ((2505, 2520), 'random.random', 'random.random', ([], {}), '()\n', (2518, 2520), False, 'import random\n')]