code: import streamlit as st 
  import os
  import openai
  import llama_index
  from llama_index.llms import OpenAI
  from llama_index.indices.composability import ComposableGraph
  from llama_index.storage import StorageContext
  from llama_index import TreeIndex, SummaryIndex
  from llama_index.indices.loading import load_graph_from_storage
  
  from llama_index.indices.loading import load_graph_from_storage
  from llama_index.storage import StorageContext
  import streamlit as st
  import openai
  openai.api_key= st.secrets['OPENAI_API_KEY']
  
  
  st.set_page_config(page_title="Chat with AAPL 23 10-Qs, powered by Munger", page_icon=":chart_with_upwards_trend:", layout="centered", initial_sidebar_state="auto", menu_items=None)
  st.title("Chat with Munger :chart_with_upwards_trend: :eyeglasses:")
  
  if "messages" not in st.session_state.keys(): # Initialize the chat messages history
      st.session_state.messages = [
          {"role": "assistant", "content": "Ask me a question about Apple's 2023 financial documents!"}
      ]
  
  
  @st.cache_resource(show_spinner=False)
  def load_data():
      with st.spinner(text="Loading and indexing the AAPL 2023 10-Q docs – hang tight! This should take 1-2 minutes."):
  
          # Create a storage context using the persist directory
          storage_context = StorageContext.from_defaults(persist_dir='./storage')
  
          # Load the graph from the storage context
          graph = load_graph_from_storage(storage_context, root_id="APPL-23")
  
          query_engine = graph.as_query_engine(child_branch_factor=1)
          
          return query_engine
  
  query_engine =load_data()
  
  if prompt := st.chat_input("Your question"): # Prompt for user input and save to chat history
      st.session_state.messages.append({"role": "user", "content": prompt})
  
  for message in st.session_state.messages: # Display the prior chat messages
      with st.chat_message(message["role"]):
          st.write(message["content"])
          
  # If last message is not from assistant, generate a new response
  if st.session_state.messages[-1]["role"] != "assistant":
      with st.chat_message("assistant"):
          with st.spinner("Thinking..."):
              response = query_engine.query(prompt)
              #ipdb.set_trace()
              st.write(response.response)
              #st.code(response.get_formatted_sources())
              message = {"role": "assistant", "content": response.response}
              st.session_state.messages.append(message) # Add response to message history        
  
apis: llama_index.storage.StorageContext.from_defaults llama_index.indices.loading.load_graph_from_storage
extract_api: [((520, 709), 'streamlit.set_page_config', 'st.set_page_config', ([], {'page_title': '"""Chat with AAPL 23 10-Qs, powered by Munger"""', 'page_icon': '""":chart_with_upwards_trend:"""', 'layout': '"""centered"""', 'initial_sidebar_state': '"""auto"""', 'menu_items': 'None'}), "(page_title='Chat with AAPL 23 10-Qs, powered by Munger',\n    page_icon=':chart_with_upwards_trend:', layout='centered',\n    initial_sidebar_state='auto', menu_items=None)\n", (538, 709), True, 'import streamlit as st\n'), ((702, 770), 'streamlit.title', 'st.title', (['"""Chat with Munger :chart_with_upwards_trend: :eyeglasses:"""'], {}), "('Chat with Munger :chart_with_upwards_trend: :eyeglasses:')\n", (710, 770), True, 'import streamlit as st\n'), ((1002, 1039), 'streamlit.cache_resource', 'st.cache_resource', ([], {'show_spinner': '(False)'}), '(show_spinner=False)\n', (1019, 1039), True, 'import streamlit as st\n'), ((793, 816), 'streamlit.session_state.keys', 'st.session_state.keys', ([], {}), '()\n', (814, 816), True, 'import streamlit as st\n'), ((1593, 1623), 'streamlit.chat_input', 'st.chat_input', (['"""Your question"""'], {}), "('Your question')\n", (1606, 1623), True, 'import streamlit as st\n'), ((1678, 1747), 'streamlit.session_state.messages.append', 'st.session_state.messages.append', (["{'role': 'user', 'content': prompt}"], {}), "({'role': 'user', 'content': prompt})\n", (1710, 1747), True, 'import streamlit as st\n'), ((1066, 1183), 'streamlit.spinner', 'st.spinner', ([], {'text': '"""Loading and indexing the AAPL 2023 10-Q docs – hang tight! This should take 1-2 minutes."""'}), "(text=\n    'Loading and indexing the AAPL 2023 10-Q docs – hang tight! This should take 1-2 minutes.'\n    )\n", (1076, 1183), True, 'import streamlit as st\n'), ((1265, 1318), 'llama_index.storage.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'persist_dir': '"""./storage"""'}), "(persist_dir='./storage')\n", (1293, 1318), False, 'from llama_index.storage import StorageContext\n'), ((1386, 1445), 'llama_index.indices.loading.load_graph_from_storage', 'load_graph_from_storage', (['storage_context'], {'root_id': '"""APPL-23"""'}), "(storage_context, root_id='APPL-23')\n", (1409, 1445), False, 'from llama_index.indices.loading import load_graph_from_storage\n'), ((1834, 1866), 'streamlit.chat_message', 'st.chat_message', (["message['role']"], {}), "(message['role'])\n", (1849, 1866), True, 'import streamlit as st\n'), ((1876, 1904), 'streamlit.write', 'st.write', (["message['content']"], {}), "(message['content'])\n", (1884, 1904), True, 'import streamlit as st\n'), ((2045, 2073), 'streamlit.chat_message', 'st.chat_message', (['"""assistant"""'], {}), "('assistant')\n", (2060, 2073), True, 'import streamlit as st\n'), ((2088, 2113), 'streamlit.spinner', 'st.spinner', (['"""Thinking..."""'], {}), "('Thinking...')\n", (2098, 2113), True, 'import streamlit as st\n'), ((2207, 2234), 'streamlit.write', 'st.write', (['response.response'], {}), '(response.response)\n', (2215, 2234), True, 'import streamlit as st\n'), ((2376, 2417), 'streamlit.session_state.messages.append', 'st.session_state.messages.append', (['message'], {}), '(message)\n', (2408, 2417), True, 'import streamlit as st\n')]