code: import os, streamlit as st
  
  # Uncomment to specify your OpenAI API key here (local testing only, not in production!), or add corresponding environment variable (recommended)
  # os.environ['OPENAI_API_KEY']= ""
  
  from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext
  from langchain.llms.openai import OpenAI
  
  # Define a simple Streamlit app
  st.title("Ask Llama")
  query = st.text_input("What would you like to ask? (source: data/Create.txt)", "")
  
  # If the 'Submit' button is clicked
  if st.button("Submit"):
      if not query.strip():
          st.error(f"Please provide the search query.")
      else:
          try:
              # This example uses text-davinci-003 by default; feel free to change if desired
              llm_predictor = LLMPredictor(llm=OpenAI(temperature=0, model_name="text-davinci-003"))
  
              # Configure prompt parameters and initialise helper
              max_input_size = 4096
              num_output = 256
              max_chunk_overlap = 20
  
              prompt_helper = PromptHelper(max_input_size, num_output, max_chunk_overlap)
  
              # Load documents from the 'data' directory
              documents = SimpleDirectoryReader('data').load_data()
              service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, prompt_helper=prompt_helper)
              index = GPTSimpleVectorIndex.from_documents(documents, service_context=service_context)
              
              response = index.query(query)
              st.success(response)
          except Exception as e:
              st.error(f"An error occurred: {e}")
  
apis: llama_index.PromptHelper llama_index.GPTSimpleVectorIndex.from_documents llama_index.ServiceContext.from_defaults llama_index.SimpleDirectoryReader
extract_api: [((396, 417), 'streamlit.title', 'st.title', (['"""Ask Llama"""'], {}), "('Ask Llama')\n", (404, 417), True, 'import os, streamlit as st\n'), ((426, 500), 'streamlit.text_input', 'st.text_input', (['"""What would you like to ask? (source: data/Create.txt)"""', '""""""'], {}), "('What would you like to ask? (source: data/Create.txt)', '')\n", (439, 500), True, 'import os, streamlit as st\n'), ((541, 560), 'streamlit.button', 'st.button', (['"""Submit"""'], {}), "('Submit')\n", (550, 560), True, 'import os, streamlit as st\n'), ((596, 641), 'streamlit.error', 'st.error', (['f"""Please provide the search query."""'], {}), "(f'Please provide the search query.')\n", (604, 641), True, 'import os, streamlit as st\n'), ((1048, 1107), 'llama_index.PromptHelper', 'PromptHelper', (['max_input_size', 'num_output', 'max_chunk_overlap'], {}), '(max_input_size, num_output, max_chunk_overlap)\n', (1060, 1107), False, 'from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext\n'), ((1260, 1351), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm_predictor': 'llm_predictor', 'prompt_helper': 'prompt_helper'}), '(llm_predictor=llm_predictor, prompt_helper=\n    prompt_helper)\n', (1288, 1351), False, 'from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext\n'), ((1367, 1446), 'llama_index.GPTSimpleVectorIndex.from_documents', 'GPTSimpleVectorIndex.from_documents', (['documents'], {'service_context': 'service_context'}), '(documents, service_context=service_context)\n', (1402, 1446), False, 'from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext\n'), ((1514, 1534), 'streamlit.success', 'st.success', (['response'], {}), '(response)\n', (1524, 1534), True, 'import os, streamlit as st\n'), ((1578, 1613), 'streamlit.error', 'st.error', (['f"""An error occurred: {e}"""'], {}), "(f'An error occurred: {e}')\n", (1586, 1613), True, 'import os, streamlit as st\n'), ((802, 854), 'langchain.llms.openai.OpenAI', 'OpenAI', ([], {'temperature': '(0)', 'model_name': '"""text-davinci-003"""'}), "(temperature=0, model_name='text-davinci-003')\n", (808, 854), False, 'from langchain.llms.openai import OpenAI\n'), ((1188, 1217), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""data"""'], {}), "('data')\n", (1209, 1217), False, 'from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext\n')]