code: import numpy as np
  from llama_index.core import StorageContext, load_index_from_storage
  from llama_index.llms.litellm import LiteLLM
  
  from langchain_google_genai import ChatGoogleGenerativeAI
  from trulens_eval.feedback.provider.langchain import Langchain
  from trulens_eval import Tru, Feedback, TruLlama
  from trulens_eval.feedback import Groundedness
  
  # Setup RAG
  index = load_index_from_storage(
      StorageContext.from_defaults(persist_dir="base_index"),
      embed_model="local:../models/bge-small-en-v1.5",
  )
  
  llm = LiteLLM(model="gemini/gemini-pro", temperature=0.1)
  query_engine = index.as_query_engine(llm=llm)
  
  
  # Evaluate with trulens-eval
  
  # Define provider and database
  _llm = ChatGoogleGenerativeAI(model="gemini-pro", temperature=0)
  provider = Langchain(chain=_llm)
  
  database_url = "sqlite:///data/trulens.db"
  tru = Tru(database_url=database_url, database_redact_keys=True)
  # tru.reset_database()
  
  
  # Using TruLlama
  f_qa_relevance = Feedback(
      provider.relevance_with_cot_reasons, name="Answer Relevance"
  ).on_input_output()
  
  f_context_relevance = (
      Feedback(provider.relevance_with_cot_reasons, name="Context Relevance")
      .on_input()
      .on(TruLlama.select_source_nodes().node.text)
      .aggregate(np.mean)
  )
  
  grounded = Groundedness(groundedness_provider=provider)
  f_groundedness = (
      Feedback(grounded.groundedness_measure_with_cot_reasons, name="Groundedness")
      .on(TruLlama.select_source_nodes().node.text)
      .on_output()
      .aggregate(grounded.grounded_statements_aggregator)
  )
  
  app_id = "Chain2"
  
  tru_recorder = TruLlama(
      query_engine,
      app_id=app_id,
      feedbacks=[
          f_qa_relevance,
          f_context_relevance,
          f_groundedness,
      ],
  )
  
  qns = ...
  for qn in qns:
      with tru_recorder as recording:
          res = query_engine.query(qn)
  
  
  # Results
  # dashboard
  tru.run_dashboard(port=8601)
  
  # # dataframe
  # records_df, feednack = tru.get_records_and_feednack(app_ids=[app_id])
  # records_df.head()
  
apis: llama_index.llms.litellm.LiteLLM llama_index.core.StorageContext.from_defaults
extract_api: [((519, 570), 'llama_index.llms.litellm.LiteLLM', 'LiteLLM', ([], {'model': '"""gemini/gemini-pro"""', 'temperature': '(0.1)'}), "(model='gemini/gemini-pro', temperature=0.1)\n", (526, 570), False, 'from llama_index.llms.litellm import LiteLLM\n'), ((687, 744), 'langchain_google_genai.ChatGoogleGenerativeAI', 'ChatGoogleGenerativeAI', ([], {'model': '"""gemini-pro"""', 'temperature': '(0)'}), "(model='gemini-pro', temperature=0)\n", (709, 744), False, 'from langchain_google_genai import ChatGoogleGenerativeAI\n'), ((756, 777), 'trulens_eval.feedback.provider.langchain.Langchain', 'Langchain', ([], {'chain': '_llm'}), '(chain=_llm)\n', (765, 777), False, 'from trulens_eval.feedback.provider.langchain import Langchain\n'), ((828, 885), 'trulens_eval.Tru', 'Tru', ([], {'database_url': 'database_url', 'database_redact_keys': '(True)'}), '(database_url=database_url, database_redact_keys=True)\n', (831, 885), False, 'from trulens_eval import Tru, Feedback, TruLlama\n'), ((1245, 1289), 'trulens_eval.feedback.Groundedness', 'Groundedness', ([], {'groundedness_provider': 'provider'}), '(groundedness_provider=provider)\n', (1257, 1289), False, 'from trulens_eval.feedback import Groundedness\n'), ((1551, 1657), 'trulens_eval.TruLlama', 'TruLlama', (['query_engine'], {'app_id': 'app_id', 'feedbacks': '[f_qa_relevance, f_context_relevance, f_groundedness]'}), '(query_engine, app_id=app_id, feedbacks=[f_qa_relevance,\n    f_context_relevance, f_groundedness])\n', (1559, 1657), False, 'from trulens_eval import Tru, Feedback, TruLlama\n'), ((401, 455), 'llama_index.core.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'persist_dir': '"""base_index"""'}), "(persist_dir='base_index')\n", (429, 455), False, 'from llama_index.core import StorageContext, load_index_from_storage\n'), ((945, 1015), 'trulens_eval.Feedback', 'Feedback', (['provider.relevance_with_cot_reasons'], {'name': '"""Answer Relevance"""'}), "(provider.relevance_with_cot_reasons, name='Answer Relevance')\n", (953, 1015), False, 'from trulens_eval import Tru, Feedback, TruLlama\n'), ((1165, 1195), 'trulens_eval.TruLlama.select_source_nodes', 'TruLlama.select_source_nodes', ([], {}), '()\n', (1193, 1195), False, 'from trulens_eval import Tru, Feedback, TruLlama\n'), ((1069, 1140), 'trulens_eval.Feedback', 'Feedback', (['provider.relevance_with_cot_reasons'], {'name': '"""Context Relevance"""'}), "(provider.relevance_with_cot_reasons, name='Context Relevance')\n", (1077, 1140), False, 'from trulens_eval import Tru, Feedback, TruLlama\n'), ((1313, 1390), 'trulens_eval.Feedback', 'Feedback', (['grounded.groundedness_measure_with_cot_reasons'], {'name': '"""Groundedness"""'}), "(grounded.groundedness_measure_with_cot_reasons, name='Groundedness')\n", (1321, 1390), False, 'from trulens_eval import Tru, Feedback, TruLlama\n'), ((1399, 1429), 'trulens_eval.TruLlama.select_source_nodes', 'TruLlama.select_source_nodes', ([], {}), '()\n', (1427, 1429), False, 'from trulens_eval import Tru, Feedback, TruLlama\n')]