code: import streamlit as st
  import openai
  from llama_index.storage.docstore import SimpleDocumentStore
  from llama_index.vector_stores import FaissVectorStore
  from llama_index.storage.index_store import SimpleIndexStore
  
  from llama_index import load_index_from_storage
  from llama_index.storage.storage_context import StorageContext
  from llama_index.query_engine import CitationQueryEngine
  
  @st.cache_resource
  def preprocess_prelimnary():
      storage_context = StorageContext.from_defaults(docstore = SimpleDocumentStore.from_persist_dir(persist_dir = "persist_new"),
          vector_store = FaissVectorStore.from_persist_dir(persist_dir = "persist_new"),
          index_store = SimpleIndexStore.from_persist_dir(persist_dir = "persist_new"))
      index = load_index_from_storage(storage_context = storage_context)
      query_engine = CitationQueryEngine.from_args(index, similarity_top_k = 3, citation_chunk_size = 1024)
      return query_engine
  
  openai.api_key = st.secrets['OPENAI_API_KEY']
  
  st.set_page_config(layout = 'wide', page_title = 'Precedents Database')
  
  st.title('Query Precedents')
  
  q_e = preprocess_prelimnary()
  
  query = st.text_area(label = 'Enter your query involving Indian Legal Precedents.')
  # model = st.selectbox(label = 'Select a model', options = ['gpt-3.5-turbo', 'gpt-4'])
  
  start = st.button(label = 'Start')
  
  base_append = ""
  
  if start:
      st.subheader('Query Response -')
      database_answer = q_e.query(query + base_append)
      st.write(database_answer.response)
      st.subheader('Actual Sources -')
      for i in range(len(database_answer.source_nodes)):
          st.write(database_answer.source_nodes[i].node.get_text())
          st.write(f'Case Name - {database_answer.source_nodes[i].node.extra_info["file_name"]}')
apis: llama_index.storage.docstore.SimpleDocumentStore.from_persist_dir llama_index.vector_stores.FaissVectorStore.from_persist_dir llama_index.query_engine.CitationQueryEngine.from_args llama_index.storage.index_store.SimpleIndexStore.from_persist_dir llama_index.load_index_from_storage
extract_api: [((983, 1050), 'streamlit.set_page_config', 'st.set_page_config', ([], {'layout': '"""wide"""', 'page_title': '"""Precedents Database"""'}), "(layout='wide', page_title='Precedents Database')\n", (1001, 1050), True, 'import streamlit as st\n'), ((1056, 1084), 'streamlit.title', 'st.title', (['"""Query Precedents"""'], {}), "('Query Precedents')\n", (1064, 1084), True, 'import streamlit as st\n'), ((1125, 1198), 'streamlit.text_area', 'st.text_area', ([], {'label': '"""Enter your query involving Indian Legal Precedents."""'}), "(label='Enter your query involving Indian Legal Precedents.')\n", (1137, 1198), True, 'import streamlit as st\n'), ((1297, 1321), 'streamlit.button', 'st.button', ([], {'label': '"""Start"""'}), "(label='Start')\n", (1306, 1321), True, 'import streamlit as st\n'), ((746, 802), 'llama_index.load_index_from_storage', 'load_index_from_storage', ([], {'storage_context': 'storage_context'}), '(storage_context=storage_context)\n', (769, 802), False, 'from llama_index import load_index_from_storage\n'), ((824, 910), 'llama_index.query_engine.CitationQueryEngine.from_args', 'CitationQueryEngine.from_args', (['index'], {'similarity_top_k': '(3)', 'citation_chunk_size': '(1024)'}), '(index, similarity_top_k=3,\n    citation_chunk_size=1024)\n', (853, 910), False, 'from llama_index.query_engine import CitationQueryEngine\n'), ((1357, 1389), 'streamlit.subheader', 'st.subheader', (['"""Query Response -"""'], {}), "('Query Response -')\n", (1369, 1389), True, 'import streamlit as st\n'), ((1447, 1481), 'streamlit.write', 'st.write', (['database_answer.response'], {}), '(database_answer.response)\n', (1455, 1481), True, 'import streamlit as st\n'), ((1486, 1518), 'streamlit.subheader', 'st.subheader', (['"""Actual Sources -"""'], {}), "('Actual Sources -')\n", (1498, 1518), True, 'import streamlit as st\n'), ((1648, 1745), 'streamlit.write', 'st.write', (['f"""Case Name - {database_answer.source_nodes[i].node.extra_info[\'file_name\']}"""'], {}), '(\n    f"Case Name - {database_answer.source_nodes[i].node.extra_info[\'file_name\']}"\n    )\n', (1656, 1745), True, 'import streamlit as st\n'), ((494, 557), 'llama_index.storage.docstore.SimpleDocumentStore.from_persist_dir', 'SimpleDocumentStore.from_persist_dir', ([], {'persist_dir': '"""persist_new"""'}), "(persist_dir='persist_new')\n", (530, 557), False, 'from llama_index.storage.docstore import SimpleDocumentStore\n'), ((584, 644), 'llama_index.vector_stores.FaissVectorStore.from_persist_dir', 'FaissVectorStore.from_persist_dir', ([], {'persist_dir': '"""persist_new"""'}), "(persist_dir='persist_new')\n", (617, 644), False, 'from llama_index.vector_stores import FaissVectorStore\n'), ((670, 730), 'llama_index.storage.index_store.SimpleIndexStore.from_persist_dir', 'SimpleIndexStore.from_persist_dir', ([], {'persist_dir': '"""persist_new"""'}), "(persist_dir='persist_new')\n", (703, 730), False, 'from llama_index.storage.index_store import SimpleIndexStore\n')]