code: from llama_index.core import (
      SimpleDirectoryReader, 
      VectorStoreIndex, 
      set_global_handler
  )
  import phoenix as px
  
  px.launch_app()
  set_global_handler("arize_phoenix")
  
  documents = SimpleDirectoryReader('files').load_data()
  index = VectorStoreIndex.from_documents(documents)
  qe = index.as_query_engine()
  response1 = qe.query("Tell me about ancient Rome")
  response2 = qe.query("Where is the Colosseum?")
  print(str(response1)+"\n"+str(response2))
  
  # EVALUATION PART 
  # adapted from the examples available on the official Phoenix documentation: https://docs.arize.com/phoenix/
  
  from phoenix.session.evaluation import (
      get_qa_with_reference, 
      get_retrieved_documents
  )
  from phoenix.trace import DocumentEvaluations, SpanEvaluations
  from phoenix.experimental.evals import (
      HallucinationEvaluator,
      QAEvaluator,
      RelevanceEvaluator,
      OpenAIModel,
      run_evals
  )
  model = OpenAIModel(model="gpt-4-turbo-preview")
  
  retrieved_documents_df = get_retrieved_documents(px.Client())
  queries_df = get_qa_with_reference(px.Client())
  
  hallucination_evaluator = HallucinationEvaluator(model)
  qa_correctness_evaluator = QAEvaluator(model)
  relevance_evaluator = RelevanceEvaluator(model)
  
  hallucination_eval_df, qa_correctness_eval_df = run_evals(
      dataframe=queries_df,
      evaluators=[hallucination_evaluator, qa_correctness_evaluator],
      provide_explanation=True,
  )
  relevance_eval_df = run_evals(
      dataframe=retrieved_documents_df,
      evaluators=[relevance_evaluator],
      provide_explanation=True,
  )[0]
  
  px.Client().log_evaluations(
      SpanEvaluations(
          eval_name="Hallucination", 
          dataframe=hallucination_eval_df),
      SpanEvaluations(
          eval_name="QA Correctness", 
          dataframe=qa_correctness_eval_df),
      DocumentEvaluations(
          eval_name="Relevance", 
          dataframe=relevance_eval_df),
  )
  
  input("Press <ENTER> to exit...")
  
apis: llama_index.core.set_global_handler llama_index.core.VectorStoreIndex.from_documents llama_index.core.SimpleDirectoryReader
extract_api: [((129, 144), 'phoenix.launch_app', 'px.launch_app', ([], {}), '()\n', (142, 144), True, 'import phoenix as px\n'), ((145, 180), 'llama_index.core.set_global_handler', 'set_global_handler', (['"""arize_phoenix"""'], {}), "('arize_phoenix')\n", (163, 180), False, 'from llama_index.core import SimpleDirectoryReader, VectorStoreIndex, set_global_handler\n'), ((245, 287), 'llama_index.core.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['documents'], {}), '(documents)\n', (276, 287), False, 'from llama_index.core import SimpleDirectoryReader, VectorStoreIndex, set_global_handler\n'), ((901, 941), 'phoenix.experimental.evals.OpenAIModel', 'OpenAIModel', ([], {'model': '"""gpt-4-turbo-preview"""'}), "(model='gpt-4-turbo-preview')\n", (912, 941), False, 'from phoenix.experimental.evals import HallucinationEvaluator, QAEvaluator, RelevanceEvaluator, OpenAIModel, run_evals\n'), ((1080, 1109), 'phoenix.experimental.evals.HallucinationEvaluator', 'HallucinationEvaluator', (['model'], {}), '(model)\n', (1102, 1109), False, 'from phoenix.experimental.evals import HallucinationEvaluator, QAEvaluator, RelevanceEvaluator, OpenAIModel, run_evals\n'), ((1137, 1155), 'phoenix.experimental.evals.QAEvaluator', 'QAEvaluator', (['model'], {}), '(model)\n', (1148, 1155), False, 'from phoenix.experimental.evals import HallucinationEvaluator, QAEvaluator, RelevanceEvaluator, OpenAIModel, run_evals\n'), ((1178, 1203), 'phoenix.experimental.evals.RelevanceEvaluator', 'RelevanceEvaluator', (['model'], {}), '(model)\n', (1196, 1203), False, 'from phoenix.experimental.evals import HallucinationEvaluator, QAEvaluator, RelevanceEvaluator, OpenAIModel, run_evals\n'), ((1253, 1378), 'phoenix.experimental.evals.run_evals', 'run_evals', ([], {'dataframe': 'queries_df', 'evaluators': '[hallucination_evaluator, qa_correctness_evaluator]', 'provide_explanation': '(True)'}), '(dataframe=queries_df, evaluators=[hallucination_evaluator,\n    qa_correctness_evaluator], provide_explanation=True)\n', (1262, 1378), False, 'from phoenix.experimental.evals import HallucinationEvaluator, QAEvaluator, RelevanceEvaluator, OpenAIModel, run_evals\n'), ((992, 1003), 'phoenix.Client', 'px.Client', ([], {}), '()\n', (1001, 1003), True, 'import phoenix as px\n'), ((1040, 1051), 'phoenix.Client', 'px.Client', ([], {}), '()\n', (1049, 1051), True, 'import phoenix as px\n'), ((1410, 1518), 'phoenix.experimental.evals.run_evals', 'run_evals', ([], {'dataframe': 'retrieved_documents_df', 'evaluators': '[relevance_evaluator]', 'provide_explanation': '(True)'}), '(dataframe=retrieved_documents_df, evaluators=[relevance_evaluator\n    ], provide_explanation=True)\n', (1419, 1518), False, 'from phoenix.experimental.evals import HallucinationEvaluator, QAEvaluator, RelevanceEvaluator, OpenAIModel, run_evals\n'), ((1566, 1641), 'phoenix.trace.SpanEvaluations', 'SpanEvaluations', ([], {'eval_name': '"""Hallucination"""', 'dataframe': 'hallucination_eval_df'}), "(eval_name='Hallucination', dataframe=hallucination_eval_df)\n", (1581, 1641), False, 'from phoenix.trace import DocumentEvaluations, SpanEvaluations\n'), ((1665, 1742), 'phoenix.trace.SpanEvaluations', 'SpanEvaluations', ([], {'eval_name': '"""QA Correctness"""', 'dataframe': 'qa_correctness_eval_df'}), "(eval_name='QA Correctness', dataframe=qa_correctness_eval_df)\n", (1680, 1742), False, 'from phoenix.trace import DocumentEvaluations, SpanEvaluations\n'), ((1766, 1837), 'phoenix.trace.DocumentEvaluations', 'DocumentEvaluations', ([], {'eval_name': '"""Relevance"""', 'dataframe': 'relevance_eval_df'}), "(eval_name='Relevance', dataframe=relevance_eval_df)\n", (1785, 1837), False, 'from phoenix.trace import DocumentEvaluations, SpanEvaluations\n'), ((194, 224), 'llama_index.core.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""files"""'], {}), "('files')\n", (215, 224), False, 'from llama_index.core import SimpleDirectoryReader, VectorStoreIndex, set_global_handler\n'), ((1533, 1544), 'phoenix.Client', 'px.Client', ([], {}), '()\n', (1542, 1544), True, 'import phoenix as px\n')]