code: import sys
  import os
  
  sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
  
  import asyncio
  from models.memory_models import (Message)
  from services.config import get_option
  from services.logger import setup_logger
  from utilities.queue_utils import setup_queue, process_queue
  from elasticsearch import AsyncElasticsearch
  import llama_index
  from llama_index import (ServiceContext, SimpleDirectoryReader, VectorStoreIndex, Document)
  from llama_index.llms import OpenAI
  from llama_index.embeddings import HuggingFaceEmbedding    
  from llama_index.vector_stores import ElasticsearchStore
  from llama_index.storage.storage_context import StorageContext
  from memorybank.services import llamaindex_index_factory as esutils
  
  
  # Get the Azure storage connection string and the save message queue from environment variables
  AZURE_STORAGE_CONNECTION_STRING = get_option('AZURE_STORAGE_CONNECTION_STRING', is_required=True)
  SAVE_MESSAGE_QUEUE = get_option('SAVE_MESSAGE_QUEUE', is_required=True)
  
  DELETE_QUEUE = False
  REMOVE_MESSAGES = True
  
  # Set up logging
  logger = setup_logger(__name__)
  
  # Functionality
  
  async def main():
      index = await esutils.get_index()
      
      def index_message(resource_dict):
          message = Message(**resource_dict)
          # For now we just print a message
          doc = Document(
              text=message.text,
              metadata={"collection": message.collection, "author": "user" },
          )
          
          index.insert(doc)
          
          print(f"Saving message '{message.text}' in collection {message.collection}")    
      
      queue_service = setup_queue(AZURE_STORAGE_CONNECTION_STRING, SAVE_MESSAGE_QUEUE, DELETE_QUEUE)
      process_queue(queue_service, SAVE_MESSAGE_QUEUE, index_message, logger, REMOVE_MESSAGES)
      
  if __name__ == "__main__":
      asyncio.run(main())
apis: llama_index.Document
extract_api: [((877, 940), 'services.config.get_option', 'get_option', (['"""AZURE_STORAGE_CONNECTION_STRING"""'], {'is_required': '(True)'}), "('AZURE_STORAGE_CONNECTION_STRING', is_required=True)\n", (887, 940), False, 'from services.config import get_option\n'), ((962, 1012), 'services.config.get_option', 'get_option', (['"""SAVE_MESSAGE_QUEUE"""'], {'is_required': '(True)'}), "('SAVE_MESSAGE_QUEUE', is_required=True)\n", (972, 1012), False, 'from services.config import get_option\n'), ((1085, 1107), 'services.logger.setup_logger', 'setup_logger', (['__name__'], {}), '(__name__)\n', (1097, 1107), False, 'from services.logger import setup_logger\n'), ((1609, 1687), 'utilities.queue_utils.setup_queue', 'setup_queue', (['AZURE_STORAGE_CONNECTION_STRING', 'SAVE_MESSAGE_QUEUE', 'DELETE_QUEUE'], {}), '(AZURE_STORAGE_CONNECTION_STRING, SAVE_MESSAGE_QUEUE, DELETE_QUEUE)\n', (1620, 1687), False, 'from utilities.queue_utils import setup_queue, process_queue\n'), ((1692, 1784), 'utilities.queue_utils.process_queue', 'process_queue', (['queue_service', 'SAVE_MESSAGE_QUEUE', 'index_message', 'logger', 'REMOVE_MESSAGES'], {}), '(queue_service, SAVE_MESSAGE_QUEUE, index_message, logger,\n    REMOVE_MESSAGES)\n', (1705, 1784), False, 'from utilities.queue_utils import setup_queue, process_queue\n'), ((1162, 1181), 'memorybank.services.llamaindex_index_factory.get_index', 'esutils.get_index', ([], {}), '()\n', (1179, 1181), True, 'from memorybank.services import llamaindex_index_factory as esutils\n'), ((1243, 1267), 'models.memory_models.Message', 'Message', ([], {}), '(**resource_dict)\n', (1250, 1267), False, 'from models.memory_models import Message\n'), ((1324, 1418), 'llama_index.Document', 'Document', ([], {'text': 'message.text', 'metadata': "{'collection': message.collection, 'author': 'user'}"}), "(text=message.text, metadata={'collection': message.collection,\n    'author': 'user'})\n", (1332, 1418), False, 'from llama_index import ServiceContext, SimpleDirectoryReader, VectorStoreIndex, Document\n'), ((70, 95), 'os.path.dirname', 'os.path.dirname', (['__file__'], {}), '(__file__)\n', (85, 95), False, 'import os\n')]