code: import os
  from django.conf import settings
  from django.http import JsonResponse
  from django.views import View
  import llama_index
  from llama_index import (StorageContext, 
                           load_index_from_storage, 
                           ServiceContext, 
                           set_global_service_context,
                           get_response_synthesizer)
  from llama_index.llms import OpenAI
  from llama_index.retrievers import VectorIndexRetriever,SummaryIndexLLMRetriever
  from llama_index.query_engine import RetrieverQueryEngine
  from llama_index.indices.postprocessor import SimilarityPostprocessor
  from llama_index.callbacks import CallbackManager, WandbCallbackHandler
  from llama_index import set_global_handler,global_handler
  from llama_index.prompts import PromptTemplate
  from IPython.display import Markdown, display
  
  llama_index.set_global_handler("simple")
  
  # define LLM
  llm = OpenAI(model="gpt-3.5-turbo", temperature=0, max_tokens=200, api_key=os.getenv("OPENAI_API_KEY"))
  
  # configure service context
  service_context = ServiceContext.from_defaults(llm=llm)
  set_global_service_context(service_context)
  
  # define prompt viewing function
  def display_prompt_dict(prompts_dict):
      for k, p in prompts_dict.items():
          text_md = f"**Prompt Key**: {k}<br>" f"**Text:** <br>"
          display(Markdown(text_md))
          print(p.get_template())
          display(Markdown("<br><br>"))
  
  index_file_path = os.path.join('../indexed_documents')
  # rebuild storage context
  storage_context = StorageContext.from_defaults(persist_dir=index_file_path)
  # load index
  index = load_index_from_storage(storage_context)
  
  retriever = VectorIndexRetriever(
      index=index,
      similarity_top_k=2,
  )
  
  nodes = retriever.retrieve("国有资产管理的问题有哪些？")
  
  # configure response synthesizer
  response_synthesizer = get_response_synthesizer()
  
  # assemble query engine
  query_engine = RetrieverQueryEngine(
      retriever=retriever,
      response_synthesizer=response_synthesizer,
      node_postprocessors=[
          SimilarityPostprocessor(similarity_cutoff=0.9)
      ]
  )
  
  new_summary_tmpl_str = (
      "The necessary materials and information are provided below.\n"
      "---------------------\n"
      "{context_str}\n"
      "---------------------\n"
      "Utilizing the provided materials and your knowledge, "
      "compose a detailed report.\n"
      "Task: {query_str}\n"
      "Answer: "
  )
  
  new_summary_tmpl = PromptTemplate(new_summary_tmpl_str)
  query_engine.update_prompts(
      {"response_synthesizer:text_qa_template": new_summary_tmpl}
  )
  prompts_dict = query_engine.get_prompts()
  display_prompt_dict(prompts_dict)
  
apis: llama_index.get_response_synthesizer llama_index.ServiceContext.from_defaults llama_index.StorageContext.from_defaults llama_index.prompts.PromptTemplate llama_index.set_global_handler llama_index.retrievers.VectorIndexRetriever llama_index.load_index_from_storage llama_index.indices.postprocessor.SimilarityPostprocessor llama_index.set_global_service_context
extract_api: [((837, 877), 'llama_index.set_global_handler', 'llama_index.set_global_handler', (['"""simple"""'], {}), "('simple')\n", (867, 877), False, 'import llama_index\n'), ((1043, 1080), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm': 'llm'}), '(llm=llm)\n', (1071, 1080), False, 'from llama_index import StorageContext, load_index_from_storage, ServiceContext, set_global_service_context, get_response_synthesizer\n'), ((1081, 1124), 'llama_index.set_global_service_context', 'set_global_service_context', (['service_context'], {}), '(service_context)\n', (1107, 1124), False, 'from llama_index import StorageContext, load_index_from_storage, ServiceContext, set_global_service_context, get_response_synthesizer\n'), ((1423, 1459), 'os.path.join', 'os.path.join', (['"""../indexed_documents"""'], {}), "('../indexed_documents')\n", (1435, 1459), False, 'import os\n'), ((1504, 1561), 'llama_index.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'persist_dir': 'index_file_path'}), '(persist_dir=index_file_path)\n', (1532, 1561), False, 'from llama_index import StorageContext, load_index_from_storage, ServiceContext, set_global_service_context, get_response_synthesizer\n'), ((1583, 1623), 'llama_index.load_index_from_storage', 'load_index_from_storage', (['storage_context'], {}), '(storage_context)\n', (1606, 1623), False, 'from llama_index import StorageContext, load_index_from_storage, ServiceContext, set_global_service_context, get_response_synthesizer\n'), ((1637, 1690), 'llama_index.retrievers.VectorIndexRetriever', 'VectorIndexRetriever', ([], {'index': 'index', 'similarity_top_k': '(2)'}), '(index=index, similarity_top_k=2)\n', (1657, 1690), False, 'from llama_index.retrievers import VectorIndexRetriever, SummaryIndexLLMRetriever\n'), ((1804, 1830), 'llama_index.get_response_synthesizer', 'get_response_synthesizer', ([], {}), '()\n', (1828, 1830), False, 'from llama_index import StorageContext, load_index_from_storage, ServiceContext, set_global_service_context, get_response_synthesizer\n'), ((2388, 2424), 'llama_index.prompts.PromptTemplate', 'PromptTemplate', (['new_summary_tmpl_str'], {}), '(new_summary_tmpl_str)\n', (2402, 2424), False, 'from llama_index.prompts import PromptTemplate\n'), ((967, 994), 'os.getenv', 'os.getenv', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (976, 994), False, 'import os\n'), ((1315, 1332), 'IPython.display.Markdown', 'Markdown', (['text_md'], {}), '(text_md)\n', (1323, 1332), False, 'from IPython.display import Markdown, display\n'), ((1382, 1402), 'IPython.display.Markdown', 'Markdown', (['"""<br><br>"""'], {}), "('<br><br>')\n", (1390, 1402), False, 'from IPython.display import Markdown, display\n'), ((1999, 2045), 'llama_index.indices.postprocessor.SimilarityPostprocessor', 'SimilarityPostprocessor', ([], {'similarity_cutoff': '(0.9)'}), '(similarity_cutoff=0.9)\n', (2022, 2045), False, 'from llama_index.indices.postprocessor import SimilarityPostprocessor\n')]