code: # wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/examples/data/10q/uber_10q_march_2022.pdf' -O './data/uber_10q_march_2022.pdf'
  # wget "https://meetings.wmo.int/Cg-19/PublishingImages/SitePages/FINAC-43/7%20-%20EC-77-Doc%205%20Financial%20Statements%20for%202022%20(FINAC).pptx" -O './data/presentation.pptx'
  import os
  import nest_asyncio  # noqa: E402
  nest_asyncio.apply()
  
  # bring in our LLAMA_CLOUD_API_KEY
  from dotenv import load_dotenv
  load_dotenv()
  
  ##### LLAMAPARSE #####
  from llama_parse import LlamaParse
  
  llamaparse_api_key = os.getenv("LLAMA_CLOUD_API_KEY")
  
  
  #llama_parse_documents = LlamaParse(api_key=llamaparse_api_key, result_type="markdown").load_data("./data/presentation.pptx")
  #llama_parse_documents = LlamaParse(api_key=llamaparse_api_key, result_type="markdown").load_data("./data/uber_10q_march_2022.pdf")
  #llama_parse_documents = LlamaParse(api_key=llamaparse_api_key, result_type="markdown").load_data("./data/state_of_union.txt")
  
  import pickle
  # Define a function to load parsed data if available, or parse if not
  def load_or_parse_data():
      data_file = "./data/parsed_data.pkl"
      
      if os.path.exists(data_file):
          # Load the parsed data from the file
          with open(data_file, "rb") as f:
              parsed_data = pickle.load(f)
      else:
          # Perform the parsing step and store the result in llama_parse_documents
          #llama_parse_documents = LlamaParse(api_key=llamaparse_api_key, result_type="markdown").load_data("./data/uber_10q_march_2022.pdf")
          #llama_parse_documents = LlamaParse(api_key=llamaparse_api_key, result_type="markdown").load_data("./data/presentation.pptx")
          llama_parse_documents = LlamaParse(api_key=llamaparse_api_key, result_type="markdown").load_data(["./data/presentation.pptx", "./data/uber_10q_march_2022.pdf"])
  
          # Save the parsed data to a file
          with open(data_file, "wb") as f:
              pickle.dump(llama_parse_documents, f)
          
          # Set the parsed data to the variable
          parsed_data = llama_parse_documents
      
      return parsed_data
  
  # Call the function to either load or parse the data
  llama_parse_documents = load_or_parse_data()
  
  
  len(llama_parse_documents)
  
  llama_parse_documents[0].text[:100]
  
  type(llama_parse_documents)
  
  ######## QDRANT ###########
  
  from llama_index.vector_stores.qdrant import QdrantVectorStore
  from llama_index.core import VectorStoreIndex, StorageContext
  
  import qdrant_client
  
  qdrant_url = os.getenv("QDRANT_URL")
  qdrant_api_key = os.getenv("QDRANT_API_KEY")
  
  ######### FastEmbedEmbeddings #############
  
  # by default llamaindex uses OpenAI models
  from llama_index.embeddings.fastembed import FastEmbedEmbedding
  embed_model = FastEmbedEmbedding(model_name="BAAI/bge-base-en-v1.5")
  
  """ embed_model = OllamaEmbedding(
      model_name="nomic-embed-text",
      #model_name="llama2",
      base_url="http://localhost:11434",
      ollama_additional_kwargs={"mirostat": 0},
  ) """
  
  #### Setting embed_model other than openAI ( by default used openAI's model)
  from llama_index.core import Settings
  
  Settings.embed_model = embed_model
  
  ######### Groq API ###########
  
  from llama_index.llms.groq import Groq
  groq_api_key = os.getenv("GROQ_API_KEY")
  
  llm = Groq(model="mixtral-8x7b-32768", api_key=groq_api_key)
  #llm = Groq(model="gemma-7b-it", api_key=groq_api_key)
  
  ######### Ollama ###########
  
  #from llama_index.llms.ollama import Ollama  # noqa: E402
  #llm = Ollama(model="llama2", request_timeout=30.0)
  
  #### Setting llm other than openAI ( by default used openAI's model)
  Settings.llm = llm
  
  client = qdrant_client.QdrantClient(api_key=qdrant_api_key, url=qdrant_url,)
  
  vector_store = QdrantVectorStore(client=client, collection_name='qdrant_rag')
  storage_context = StorageContext.from_defaults(vector_store=vector_store)
  index = VectorStoreIndex.from_documents(documents=llama_parse_documents, storage_context=storage_context, show_progress=True)
  
  #### PERSIST INDEX #####
  #index.storage_context.persist()
  
  #storage_context = StorageContext.from_defaults(persist_dir="./storage")
  #index = load_index_from_storage(storage_context)
  
  # create a query engine for the index
  query_engine = index.as_query_engine()
  
  # query the engine
  #query = "what is the common stock balance as of Balance as of March 31, 2022?"
  query = "what is the letter of credit As of December 31, 2021 "
  response = query_engine.query(query)
  print(response)
apis: llama_index.core.StorageContext.from_defaults llama_index.vector_stores.qdrant.QdrantVectorStore llama_index.core.VectorStoreIndex.from_documents llama_index.llms.groq.Groq llama_index.embeddings.fastembed.FastEmbedEmbedding
extract_api: [((378, 398), 'nest_asyncio.apply', 'nest_asyncio.apply', ([], {}), '()\n', (396, 398), False, 'import nest_asyncio\n'), ((466, 479), 'dotenv.load_dotenv', 'load_dotenv', ([], {}), '()\n', (477, 479), False, 'from dotenv import load_dotenv\n'), ((561, 593), 'os.getenv', 'os.getenv', (['"""LLAMA_CLOUD_API_KEY"""'], {}), "('LLAMA_CLOUD_API_KEY')\n", (570, 593), False, 'import os\n'), ((2478, 2501), 'os.getenv', 'os.getenv', (['"""QDRANT_URL"""'], {}), "('QDRANT_URL')\n", (2487, 2501), False, 'import os\n'), ((2519, 2546), 'os.getenv', 'os.getenv', (['"""QDRANT_API_KEY"""'], {}), "('QDRANT_API_KEY')\n", (2528, 2546), False, 'import os\n'), ((2714, 2768), 'llama_index.embeddings.fastembed.FastEmbedEmbedding', 'FastEmbedEmbedding', ([], {'model_name': '"""BAAI/bge-base-en-v1.5"""'}), "(model_name='BAAI/bge-base-en-v1.5')\n", (2732, 2768), False, 'from llama_index.embeddings.fastembed import FastEmbedEmbedding\n'), ((3196, 3221), 'os.getenv', 'os.getenv', (['"""GROQ_API_KEY"""'], {}), "('GROQ_API_KEY')\n", (3205, 3221), False, 'import os\n'), ((3229, 3283), 'llama_index.llms.groq.Groq', 'Groq', ([], {'model': '"""mixtral-8x7b-32768"""', 'api_key': 'groq_api_key'}), "(model='mixtral-8x7b-32768', api_key=groq_api_key)\n", (3233, 3283), False, 'from llama_index.llms.groq import Groq\n'), ((3579, 3645), 'qdrant_client.QdrantClient', 'qdrant_client.QdrantClient', ([], {'api_key': 'qdrant_api_key', 'url': 'qdrant_url'}), '(api_key=qdrant_api_key, url=qdrant_url)\n', (3605, 3645), False, 'import qdrant_client\n'), ((3663, 3725), 'llama_index.vector_stores.qdrant.QdrantVectorStore', 'QdrantVectorStore', ([], {'client': 'client', 'collection_name': '"""qdrant_rag"""'}), "(client=client, collection_name='qdrant_rag')\n", (3680, 3725), False, 'from llama_index.vector_stores.qdrant import QdrantVectorStore\n'), ((3744, 3799), 'llama_index.core.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'vector_store': 'vector_store'}), '(vector_store=vector_store)\n', (3772, 3799), False, 'from llama_index.core import VectorStoreIndex, StorageContext\n'), ((3808, 3929), 'llama_index.core.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', ([], {'documents': 'llama_parse_documents', 'storage_context': 'storage_context', 'show_progress': '(True)'}), '(documents=llama_parse_documents,\n    storage_context=storage_context, show_progress=True)\n', (3839, 3929), False, 'from llama_index.core import VectorStoreIndex, StorageContext\n'), ((1145, 1170), 'os.path.exists', 'os.path.exists', (['data_file'], {}), '(data_file)\n', (1159, 1170), False, 'import os\n'), ((1284, 1298), 'pickle.load', 'pickle.load', (['f'], {}), '(f)\n', (1295, 1298), False, 'import pickle\n'), ((1928, 1965), 'pickle.dump', 'pickle.dump', (['llama_parse_documents', 'f'], {}), '(llama_parse_documents, f)\n', (1939, 1965), False, 'import pickle\n'), ((1696, 1758), 'llama_parse.LlamaParse', 'LlamaParse', ([], {'api_key': 'llamaparse_api_key', 'result_type': '"""markdown"""'}), "(api_key=llamaparse_api_key, result_type='markdown')\n", (1706, 1758), False, 'from llama_parse import LlamaParse\n')]