code: import uuid
  from llama_index import (StorageContext, VectorStoreIndex, download_loader,
                           load_index_from_storage)
  from llama_index.memory import ChatMemoryBuffer
  
  
  
  def create_index_and_query(transcript_id: str, full_transcription: any):
      persist_dir = f'./storage/cache/transcription/{transcript_id}'
  
      try:
          storage_context = StorageContext.from_defaults(persist_dir=persist_dir)
          index = load_index_from_storage(storage_context)
          print('loading from disk')
      except:
          JsonDataReader = download_loader("JsonDataReader")
          loader = JsonDataReader()
          documents = loader.load_data(full_transcription)
          index = VectorStoreIndex.from_documents(documents)
          index.storage_context.persist(persist_dir=persist_dir)
          print('creating on disk')
  
      return index
  
  
  def create_chat_engine(indexStorage: any):
      global chat_engines
      chat_id = str(uuid.uuid4()) 
  
      memory = ChatMemoryBuffer.from_defaults(token_limit=2000)
  
      chat_engine = indexStorage.as_chat_engine(
          chat_mode="context",
          memory=memory,
          system_prompt=(
              "You are a chatbot, able to have normal interactions, as well as talk"
              # " about an essay discussing Paul Grahams life."
          ),
      )
  
      chat_engines[chat_id] = chat_engine
  
      return chat_id
  
apis: llama_index.VectorStoreIndex.from_documents llama_index.StorageContext.from_defaults llama_index.download_loader llama_index.load_index_from_storage llama_index.memory.ChatMemoryBuffer.from_defaults
extract_api: [((963, 1011), 'llama_index.memory.ChatMemoryBuffer.from_defaults', 'ChatMemoryBuffer.from_defaults', ([], {'token_limit': '(2000)'}), '(token_limit=2000)\n', (993, 1011), False, 'from llama_index.memory import ChatMemoryBuffer\n'), ((365, 418), 'llama_index.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'persist_dir': 'persist_dir'}), '(persist_dir=persist_dir)\n', (393, 418), False, 'from llama_index import StorageContext, VectorStoreIndex, download_loader, load_index_from_storage\n'), ((435, 475), 'llama_index.load_index_from_storage', 'load_index_from_storage', (['storage_context'], {}), '(storage_context)\n', (458, 475), False, 'from llama_index import StorageContext, VectorStoreIndex, download_loader, load_index_from_storage\n'), ((934, 946), 'uuid.uuid4', 'uuid.uuid4', ([], {}), '()\n', (944, 946), False, 'import uuid\n'), ((548, 581), 'llama_index.download_loader', 'download_loader', (['"""JsonDataReader"""'], {}), "('JsonDataReader')\n", (563, 581), False, 'from llama_index import StorageContext, VectorStoreIndex, download_loader, load_index_from_storage\n'), ((689, 731), 'llama_index.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['documents'], {}), '(documents)\n', (720, 731), False, 'from llama_index import StorageContext, VectorStoreIndex, download_loader, load_index_from_storage\n')]