code: import llama_index
  import chromadb
  from importlib.metadata import version
  
  print(f"LlamaIndex version: {version('llama_index')}")
  print(f"Chroma version: {version('chromadb')}")
  
  # Load API key from .env file
  
  import os
  from dotenv import load_dotenv, find_dotenv
  
  load_dotenv(find_dotenv())
  
  # Define embedding model and LLM
  
  from llama_index.embeddings.openai import OpenAIEmbedding
  from llama_index.llms.openai import OpenAI
  from llama_index.core.settings import Settings
  
  Settings.llm = OpenAI(model="gpt-3.5-turbo", temperature=0.1)
  Settings.embed_model = OpenAIEmbedding()
  
  # Load the index with some example data
  
  from llama_index.core import SimpleDirectoryReader
  
  documents = SimpleDirectoryReader(
      input_files=["./data/paul_graham_essay.txt"],
  ).load_data()
  
  # Chunk documents into nodes
  
  from llama_index.core.node_parser import SentenceWindowNodeParser
  
  # create the sentence window node parser w/ default settings
  node_parser = SentenceWindowNodeParser.from_defaults(
      window_size=3,
      window_metadata_key="window",
      original_text_metadata_key="original_text",
  )
  
  # Extract nodes from documents
  nodes = node_parser.get_nodes_from_documents(documents)
  
  # Build the index
  
  client = chromadb.EphemeralClient()
  
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
  
  embed_model = HuggingFaceEmbedding(
      model_name="BAAI/bge-base-en-v1.5",
      device="cuda",
  )
  
  from llama_index.core import VectorStoreIndex, StorageContext
  from llama_index.vector_stores.chroma import ChromaVectorStore
  
  index_name = "MyExternalContent"
  
  # Construct vector store
  vector_store = ChromaVectorStore(
      chroma_collection=client.create_collection(name=index_name),
  )
  
  # Set up the storage for the embeddings
  storage_context = StorageContext.from_defaults(vector_store=vector_store)
  
  # Setup the index
  # build VectorStoreIndex that takes care of chunking documents
  # and encoding chunks to embeddings for future retrieval
  index = VectorStoreIndex(
      nodes,
      storage_context=storage_context,
      embed_model=embed_model,
  )
  
  # Setup the query engine
  
  from llama_index.core.postprocessor import MetadataReplacementPostProcessor
  
  # The target key defaults to `window` to match the node_parser's default
  postproc = MetadataReplacementPostProcessor(
      target_metadata_key="window",
  )
  
  from llama_index.core.postprocessor import SentenceTransformerRerank
  
  # Define reranker model
  rerank = SentenceTransformerRerank(
      top_n = 2, 
      model = "BAAI/bge-reranker-base",
      device = "cuda",
  )
  
  query_engine = index.as_query_engine( 
  	similarity_top_k = 6,
      vector_store_query_mode="hybrid", 
      alpha=0.5,
      node_postprocessors = [postproc, rerank],
  )
  
  # Run a query against the naive RAG implementation
  
  response = query_engine.query(
      "What happened at InterLeaf?",
  )
  print(response)
  
  window = response.source_nodes[0].node.metadata["window"]
  sentence = response.source_nodes[0].node.metadata["original_text"]
  
  print(f"Window: {window}")
  print("------------------")
  print(f"Original Sentence: {sentence}")
apis: llama_index.core.StorageContext.from_defaults llama_index.core.postprocessor.SentenceTransformerRerank llama_index.embeddings.huggingface.HuggingFaceEmbedding llama_index.core.node_parser.SentenceWindowNodeParser.from_defaults llama_index.core.VectorStoreIndex llama_index.core.postprocessor.MetadataReplacementPostProcessor llama_index.core.SimpleDirectoryReader llama_index.llms.openai.OpenAI llama_index.embeddings.openai.OpenAIEmbedding
extract_api: [((511, 557), 'llama_index.llms.openai.OpenAI', 'OpenAI', ([], {'model': '"""gpt-3.5-turbo"""', 'temperature': '(0.1)'}), "(model='gpt-3.5-turbo', temperature=0.1)\n", (517, 557), False, 'from llama_index.llms.openai import OpenAI\n'), ((582, 599), 'llama_index.embeddings.openai.OpenAIEmbedding', 'OpenAIEmbedding', ([], {}), '()\n', (597, 599), False, 'from llama_index.embeddings.openai import OpenAIEmbedding\n'), ((981, 1113), 'llama_index.core.node_parser.SentenceWindowNodeParser.from_defaults', 'SentenceWindowNodeParser.from_defaults', ([], {'window_size': '(3)', 'window_metadata_key': '"""window"""', 'original_text_metadata_key': '"""original_text"""'}), "(window_size=3, window_metadata_key=\n    'window', original_text_metadata_key='original_text')\n", (1019, 1113), False, 'from llama_index.core.node_parser import SentenceWindowNodeParser\n'), ((1252, 1278), 'chromadb.EphemeralClient', 'chromadb.EphemeralClient', ([], {}), '()\n', (1276, 1278), False, 'import chromadb\n'), ((1367, 1438), 'llama_index.embeddings.huggingface.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': '"""BAAI/bge-base-en-v1.5"""', 'device': '"""cuda"""'}), "(model_name='BAAI/bge-base-en-v1.5', device='cuda')\n", (1387, 1438), False, 'from llama_index.embeddings.huggingface import HuggingFaceEmbedding\n'), ((1812, 1867), 'llama_index.core.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'vector_store': 'vector_store'}), '(vector_store=vector_store)\n', (1840, 1867), False, 'from llama_index.core import VectorStoreIndex, StorageContext\n'), ((2020, 2106), 'llama_index.core.VectorStoreIndex', 'VectorStoreIndex', (['nodes'], {'storage_context': 'storage_context', 'embed_model': 'embed_model'}), '(nodes, storage_context=storage_context, embed_model=\n    embed_model)\n', (2036, 2106), False, 'from llama_index.core import VectorStoreIndex, StorageContext\n'), ((2316, 2378), 'llama_index.core.postprocessor.MetadataReplacementPostProcessor', 'MetadataReplacementPostProcessor', ([], {'target_metadata_key': '"""window"""'}), "(target_metadata_key='window')\n", (2348, 2378), False, 'from llama_index.core.postprocessor import MetadataReplacementPostProcessor\n'), ((2497, 2583), 'llama_index.core.postprocessor.SentenceTransformerRerank', 'SentenceTransformerRerank', ([], {'top_n': '(2)', 'model': '"""BAAI/bge-reranker-base"""', 'device': '"""cuda"""'}), "(top_n=2, model='BAAI/bge-reranker-base', device=\n    'cuda')\n", (2522, 2583), False, 'from llama_index.core.postprocessor import SentenceTransformerRerank\n'), ((289, 302), 'dotenv.find_dotenv', 'find_dotenv', ([], {}), '()\n', (300, 302), False, 'from dotenv import load_dotenv, find_dotenv\n'), ((712, 779), 'llama_index.core.SimpleDirectoryReader', 'SimpleDirectoryReader', ([], {'input_files': "['./data/paul_graham_essay.txt']"}), "(input_files=['./data/paul_graham_essay.txt'])\n", (733, 779), False, 'from llama_index.core import SimpleDirectoryReader\n'), ((108, 130), 'importlib.metadata.version', 'version', (['"""llama_index"""'], {}), "('llama_index')\n", (115, 130), False, 'from importlib.metadata import version\n'), ((160, 179), 'importlib.metadata.version', 'version', (['"""chromadb"""'], {}), "('chromadb')\n", (167, 179), False, 'from importlib.metadata import version\n')]