code: get_ipython().run_line_magic('pip', 'install llama-index-callbacks-wandb')
  get_ipython().run_line_magic('pip', 'install llama-index-llms-openai')
  
  
  import os
  from getpass import getpass
  
  if os.getenv("OPENAI_API_KEY") is None:
      os.environ["OPENAI_API_KEY"] = getpass(
          "Paste your OpenAI key from:"
          " https://platform.openai.com/account/api-keys\n"
      )
  assert os.getenv("OPENAI_API_KEY", "").startswith(
      "sk-"
  ), "This doesn't look like a valid OpenAI API key"
  print("OpenAI API key configured")
  
  
  from llama_index.core.callbacks import CallbackManager
  from llama_index.core.callbacks import LlamaDebugHandler
  from llama_index.callbacks.wandb import WandbCallbackHandler
  from llama_index.core import (
      VectorStoreIndex,
      SimpleDirectoryReader,
      SimpleKeywordTableIndex,
      StorageContext,
  )
  from llama_index.llms.openai import OpenAI
  
  
  
  from llama_index.core import Settings
  
  Settings.llm = OpenAI(model="gpt-4", temperature=0)
  
  
  
  
  import llama_index.core
  from llama_index.core import set_global_handler
  
  set_global_handler("wandb", run_args={"project": "llamaindex"})
  wandb_callback = llama_index.core.global_handler
  
  
  
  llama_debug = LlamaDebugHandler(print_trace_on_end=True)
  
  run_args = dict(
      project="llamaindex",
  )
  
  wandb_callback = WandbCallbackHandler(run_args=run_args)
  
  Settings.callback_manager = CallbackManager([llama_debug, wandb_callback])
  
  
  
  
  
  get_ipython().system("mkdir -p 'data/paul_graham/'")
  get_ipython().system("wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/examples/data/paul_graham/paul_graham_essay.txt' -O 'data/paul_graham/paul_graham_essay.txt'")
  
  
  docs = SimpleDirectoryReader("./data/paul_graham/").load_data()
  
  
  index = VectorStoreIndex.from_documents(docs)
  
  
  
  wandb_callback.persist_index(index, index_name="simple_vector_store")
  
  
  
  from llama_index.core import load_index_from_storage
  
  storage_context = wandb_callback.load_storage_context(
      artifact_url="ayut/llamaindex/simple_vector_store:v0"
  )
  
  index = load_index_from_storage(
      storage_context,
  )
  
  
  
  query_engine = index.as_query_engine()
  response = query_engine.query("What did the author do growing up?")
  print(response, sep="\n")
  
  
  
  wandb_callback.finish()
apis: llama_index.core.callbacks.LlamaDebugHandler llama_index.core.callbacks.CallbackManager llama_index.core.set_global_handler llama_index.callbacks.wandb.WandbCallbackHandler llama_index.core.VectorStoreIndex.from_documents llama_index.core.SimpleDirectoryReader llama_index.llms.openai.OpenAI llama_index.core.load_index_from_storage
extract_api: [((926, 962), 'llama_index.llms.openai.OpenAI', 'OpenAI', ([], {'model': '"""gpt-4"""', 'temperature': '(0)'}), "(model='gpt-4', temperature=0)\n", (932, 962), False, 'from llama_index.llms.openai import OpenAI\n'), ((1040, 1103), 'llama_index.core.set_global_handler', 'set_global_handler', (['"""wandb"""'], {'run_args': "{'project': 'llamaindex'}"}), "('wandb', run_args={'project': 'llamaindex'})\n", (1058, 1103), False, 'from llama_index.core import set_global_handler\n'), ((1170, 1212), 'llama_index.core.callbacks.LlamaDebugHandler', 'LlamaDebugHandler', ([], {'print_trace_on_end': '(True)'}), '(print_trace_on_end=True)\n', (1187, 1212), False, 'from llama_index.core.callbacks import LlamaDebugHandler\n'), ((1277, 1316), 'llama_index.callbacks.wandb.WandbCallbackHandler', 'WandbCallbackHandler', ([], {'run_args': 'run_args'}), '(run_args=run_args)\n', (1297, 1316), False, 'from llama_index.callbacks.wandb import WandbCallbackHandler\n'), ((1346, 1392), 'llama_index.core.callbacks.CallbackManager', 'CallbackManager', (['[llama_debug, wandb_callback]'], {}), '([llama_debug, wandb_callback])\n', (1361, 1392), False, 'from llama_index.core.callbacks import CallbackManager\n'), ((1716, 1753), 'llama_index.core.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['docs'], {}), '(docs)\n', (1747, 1753), False, 'from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, SimpleKeywordTableIndex, StorageContext\n'), ((2008, 2048), 'llama_index.core.load_index_from_storage', 'load_index_from_storage', (['storage_context'], {}), '(storage_context)\n', (2031, 2048), False, 'from llama_index.core import load_index_from_storage\n'), ((190, 217), 'os.getenv', 'os.getenv', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (199, 217), False, 'import os\n'), ((262, 357), 'getpass.getpass', 'getpass', (['"""Paste your OpenAI key from: https://platform.openai.com/account/api-keys\n"""'], {}), "(\n    'Paste your OpenAI key from: https://platform.openai.com/account/api-keys\\n'\n    )\n", (269, 357), False, 'from getpass import getpass\n'), ((380, 411), 'os.getenv', 'os.getenv', (['"""OPENAI_API_KEY"""', '""""""'], {}), "('OPENAI_API_KEY', '')\n", (389, 411), False, 'import os\n'), ((1649, 1693), 'llama_index.core.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""./data/paul_graham/"""'], {}), "('./data/paul_graham/')\n", (1670, 1693), False, 'from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, SimpleKeywordTableIndex, StorageContext\n')]