code: import dotenv 
  import os
  from llama_index.readers.github import GithubRepositoryReader, GithubClient
  from llama_index.core import (VectorStoreIndex, StorageContext, PromptTemplate, load_index_from_storage, Settings)
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
  from llama_index.llms.ollama import Ollama
  from llama_index.embeddings.openai import OpenAIEmbedding
  
  def load_environ_vars():
      dotenv.load_dotenv()
      github_token = os.environ['GITHUB_TOKEN']
      # open_api = os.environ['OPEN_API_KEY']
      if github_token is None:
          print("Add the GITHUB_TOKEN environment variable in the .env file")
          exit()
      """if open_api is None:
          print("Add the OPEN_API_KEY environment variable. Read instrucitons in the readme")
          exit()"""
      return github_token
  
  def load_data(github_token: str, owner: str, repo: str):
      github_client = GithubClient(github_token)
      
      loader = GithubRepositoryReader(
          github_client,
          owner=owner,
          repo=repo,
          filter_file_extensions=(
                  [".py", ".ipynb", ".js", ".ts", ".md"],
                  GithubRepositoryReader.FilterType.INCLUDE,
              ),
              verbose=False,
              concurrent_requests=5,
          )
      docs = loader.load_data(branch="main")
      return docs
  
  def load_embedding_model():
      embedding_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5") 
      print("embedding model loaded")
      return embedding_model
      
      
  def main():
      github_token = load_environ_vars()
      PERSIST_DIR = "./basic/storage"
      
      choice = input("Enter 1 to use OPEN API enter 0 to use loally setup llama2 model using Ollama:")
      if not os.path.exists(PERSIST_DIR):
          owner = input("Enter the username of the owner of the repo: ")
          repo = input("Enter the name of the repo: ")
          documents = load_data(github_token, owner, repo)
          try:
              if choice == '1':
                  print("Open API is being used")
                  embedding_model = OpenAIEmbedding()
                  index = VectorStoreIndex.from_documents(documents)
              else:
                  print("Ollama is being used")
                  embedding_model = load_embedding_model()
                  Settings.embed_model = embedding_model
                  
                  index = VectorStoreIndex.from_documents(
                      documents,
                      embed_model=embedding_model
                      )
          except Exception as  e:
              print(e)
              exit()
          print("Documents Indexed")
  
  
      else:
          # load the existing index
          storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR)
          index = load_index_from_storage(storage_context)
          print("Already indexed data loaded")
          
      llama = Ollama(model="llama2", request_timeout=200.0)
      Settings.llm = llama
      query_engine = index.as_query_engine(llm=llama)
      qa_prompt_tmpl_str = (
              "Context information is below.\n"
              "---------------------\n"
              "{context_str}\n"
              "---------------------\n"
              "Given the context information above I want you to think step by step to answer the query in a crisp manner, incase case you don't know the answer say 'I don't know!'.\n"
              "Query: {query_str}\n"
              "Answer: "
              )
  
      qa_prompt_tmpl = PromptTemplate(qa_prompt_tmpl_str)
      query_engine.update_prompts({"response_synthesizer:text_qa_template": qa_prompt_tmpl})
      print("Press ctr + c to exit")
      while True:
          query = input("Enter your query: ")
          response = query_engine.query(query)
          print(response)
  
      
  if __name__ == "__main__":
      main()
  
apis: llama_index.core.StorageContext.from_defaults llama_index.llms.ollama.Ollama llama_index.embeddings.huggingface.HuggingFaceEmbedding llama_index.readers.github.GithubClient llama_index.readers.github.GithubRepositoryReader llama_index.core.PromptTemplate llama_index.core.VectorStoreIndex.from_documents llama_index.core.load_index_from_storage llama_index.embeddings.openai.OpenAIEmbedding
extract_api: [((415, 435), 'dotenv.load_dotenv', 'dotenv.load_dotenv', ([], {}), '()\n', (433, 435), False, 'import dotenv\n'), ((886, 912), 'llama_index.readers.github.GithubClient', 'GithubClient', (['github_token'], {}), '(github_token)\n', (898, 912), False, 'from llama_index.readers.github import GithubRepositoryReader, GithubClient\n'), ((931, 1150), 'llama_index.readers.github.GithubRepositoryReader', 'GithubRepositoryReader', (['github_client'], {'owner': 'owner', 'repo': 'repo', 'filter_file_extensions': "(['.py', '.ipynb', '.js', '.ts', '.md'], GithubRepositoryReader.FilterType.\n    INCLUDE)", 'verbose': '(False)', 'concurrent_requests': '(5)'}), "(github_client, owner=owner, repo=repo,\n    filter_file_extensions=(['.py', '.ipynb', '.js', '.ts', '.md'],\n    GithubRepositoryReader.FilterType.INCLUDE), verbose=False,\n    concurrent_requests=5)\n", (953, 1150), False, 'from llama_index.readers.github import GithubRepositoryReader, GithubClient\n'), ((1363, 1420), 'llama_index.embeddings.huggingface.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': '"""BAAI/bge-small-en-v1.5"""'}), "(model_name='BAAI/bge-small-en-v1.5')\n", (1383, 1420), False, 'from llama_index.embeddings.huggingface import HuggingFaceEmbedding\n'), ((2826, 2871), 'llama_index.llms.ollama.Ollama', 'Ollama', ([], {'model': '"""llama2"""', 'request_timeout': '(200.0)'}), "(model='llama2', request_timeout=200.0)\n", (2832, 2871), False, 'from llama_index.llms.ollama import Ollama\n'), ((3405, 3439), 'llama_index.core.PromptTemplate', 'PromptTemplate', (['qa_prompt_tmpl_str'], {}), '(qa_prompt_tmpl_str)\n', (3419, 3439), False, 'from llama_index.core import VectorStoreIndex, StorageContext, PromptTemplate, load_index_from_storage, Settings\n'), ((1699, 1726), 'os.path.exists', 'os.path.exists', (['PERSIST_DIR'], {}), '(PERSIST_DIR)\n', (1713, 1726), False, 'import os\n'), ((2649, 2702), 'llama_index.core.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'persist_dir': 'PERSIST_DIR'}), '(persist_dir=PERSIST_DIR)\n', (2677, 2702), False, 'from llama_index.core import VectorStoreIndex, StorageContext, PromptTemplate, load_index_from_storage, Settings\n'), ((2719, 2759), 'llama_index.core.load_index_from_storage', 'load_index_from_storage', (['storage_context'], {}), '(storage_context)\n', (2742, 2759), False, 'from llama_index.core import VectorStoreIndex, StorageContext, PromptTemplate, load_index_from_storage, Settings\n'), ((2034, 2051), 'llama_index.embeddings.openai.OpenAIEmbedding', 'OpenAIEmbedding', ([], {}), '()\n', (2049, 2051), False, 'from llama_index.embeddings.openai import OpenAIEmbedding\n'), ((2076, 2118), 'llama_index.core.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['documents'], {}), '(documents)\n', (2107, 2118), False, 'from llama_index.core import VectorStoreIndex, StorageContext, PromptTemplate, load_index_from_storage, Settings\n'), ((2336, 2407), 'llama_index.core.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['documents'], {'embed_model': 'embedding_model'}), '(documents, embed_model=embedding_model)\n', (2367, 2407), False, 'from llama_index.core import VectorStoreIndex, StorageContext, PromptTemplate, load_index_from_storage, Settings\n')]