code: import os 
  import streamlit as st
  import pickle
  import time
  import langchain
  from langchain.llms import OpenAI
  from langchain.document_loaders import UnstructuredURLLoader
  from langchain.chains import RetrievalQAWithSourcesChain
  from langchain.chains.qa_with_sources.loading import load_qa_with_sources_chain
  from langchain.text_splitter import RecursiveCharacterTextSplitter
  from langchain.embeddings import OpenAIEmbeddings
  from langchain.vectorstores import FAISS
  
  os.environ.get("OPENAI_API_KEY")
  
  llm = OpenAI(temperature=0.7, max_tokens = 500)
  text_splitter = RecursiveCharacterTextSplitter(
      separators=['\n\n','\n','.',','],
      chunk_size =1000,
      chunk_overlap =200 , 
  )
  embeddings = OpenAIEmbeddings()
  
  
  st.title("News Research tool 💵📊📈📢")
  st.sidebar.title("News Articale URLS")
  
  urls = []
  for i in range(3):
      url = st.sidebar.text_input(f"URL {i+1}")
      urls.append(url)
  
  
  process_url_clicked = st.sidebar.button("Process URLS")
  
  file_path = "./vectorindex.pkl"
  main_placefolder = st.empty()
  if process_url_clicked:
      loaders = UnstructuredURLLoader(urls=urls)
      main_placefolder.text("Data Loading....Started...✅✅✅✅")
      data = loaders.load()
      main_placefolder.text("Text Splitter.....Started....✅✅✅✅")
      docs = text_splitter.split_documents(data)
      vectorindex_openai = FAISS.from_documents(docs, embeddings)
      main_placefolder.text("Embedding Vectors Started Building✅✅✅✅")
      time.sleep(2)
      with open(file_path, 'wb') as f:
          pickle.dump(vectorindex_openai, f)
  
      
      
  query = main_placefolder.text_input("Enter your query here")
  
  if query:
      if os.path.exists(file_path):
          with open(file_path, 'rb') as f:
              vectorindex = pickle.load(f)
      chain = RetrievalQAWithSourcesChain.from_llm(llm = llm , retriever= vectorindex.as_retriever())                    
      result = chain({'question': query}, return_only_outputs=True)
      st.header("Answers")
      st.write(result['answer'])
      st.header("Source")
      source = result['sources']
      if source :
          st.subheader("Source")
          sources = source.split('/n')
          for source in sources:
              st.write(source)
apis: langchain.text_splitter.RecursiveCharacterTextSplitter langchain.llms.OpenAI langchain.vectorstores.FAISS.from_documents langchain.document_loaders.UnstructuredURLLoader langchain.embeddings.OpenAIEmbeddings
extract_api: [((468, 500), 'os.environ.get', 'os.environ.get', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (482, 500), False, 'import os\n'), ((508, 547), 'langchain.llms.OpenAI', 'OpenAI', ([], {'temperature': '(0.7)', 'max_tokens': '(500)'}), '(temperature=0.7, max_tokens=500)\n', (514, 547), False, 'from langchain.llms import OpenAI\n'), ((566, 673), 'langchain.text_splitter.RecursiveCharacterTextSplitter', 'RecursiveCharacterTextSplitter', ([], {'separators': "['\\n\\n', '\\n', '.', ',']", 'chunk_size': '(1000)', 'chunk_overlap': '(200)'}), "(separators=['\\n\\n', '\\n', '.', ','],\n    chunk_size=1000, chunk_overlap=200)\n", (596, 673), False, 'from langchain.text_splitter import RecursiveCharacterTextSplitter\n'), ((699, 717), 'langchain.embeddings.OpenAIEmbeddings', 'OpenAIEmbeddings', ([], {}), '()\n', (715, 717), False, 'from langchain.embeddings import OpenAIEmbeddings\n'), ((720, 755), 'streamlit.title', 'st.title', (['"""News Research tool 💵📊📈📢"""'], {}), "('News Research tool 💵📊📈📢')\n", (728, 755), True, 'import streamlit as st\n'), ((756, 794), 'streamlit.sidebar.title', 'st.sidebar.title', (['"""News Articale URLS"""'], {}), "('News Articale URLS')\n", (772, 794), True, 'import streamlit as st\n'), ((916, 949), 'streamlit.sidebar.button', 'st.sidebar.button', (['"""Process URLS"""'], {}), "('Process URLS')\n", (933, 949), True, 'import streamlit as st\n'), ((1002, 1012), 'streamlit.empty', 'st.empty', ([], {}), '()\n', (1010, 1012), True, 'import streamlit as st\n'), ((835, 872), 'streamlit.sidebar.text_input', 'st.sidebar.text_input', (['f"""URL {i + 1}"""'], {}), "(f'URL {i + 1}')\n", (856, 872), True, 'import streamlit as st\n'), ((1051, 1083), 'langchain.document_loaders.UnstructuredURLLoader', 'UnstructuredURLLoader', ([], {'urls': 'urls'}), '(urls=urls)\n', (1072, 1083), False, 'from langchain.document_loaders import UnstructuredURLLoader\n'), ((1305, 1343), 'langchain.vectorstores.FAISS.from_documents', 'FAISS.from_documents', (['docs', 'embeddings'], {}), '(docs, embeddings)\n', (1325, 1343), False, 'from langchain.vectorstores import FAISS\n'), ((1416, 1429), 'time.sleep', 'time.sleep', (['(2)'], {}), '(2)\n', (1426, 1429), False, 'import time\n'), ((1600, 1625), 'os.path.exists', 'os.path.exists', (['file_path'], {}), '(file_path)\n', (1614, 1625), False, 'import os\n'), ((1899, 1919), 'streamlit.header', 'st.header', (['"""Answers"""'], {}), "('Answers')\n", (1908, 1919), True, 'import streamlit as st\n'), ((1924, 1950), 'streamlit.write', 'st.write', (["result['answer']"], {}), "(result['answer'])\n", (1932, 1950), True, 'import streamlit as st\n'), ((1955, 1974), 'streamlit.header', 'st.header', (['"""Source"""'], {}), "('Source')\n", (1964, 1974), True, 'import streamlit as st\n'), ((1475, 1509), 'pickle.dump', 'pickle.dump', (['vectorindex_openai', 'f'], {}), '(vectorindex_openai, f)\n', (1486, 1509), False, 'import pickle\n'), ((2030, 2052), 'streamlit.subheader', 'st.subheader', (['"""Source"""'], {}), "('Source')\n", (2042, 2052), True, 'import streamlit as st\n'), ((1694, 1708), 'pickle.load', 'pickle.load', (['f'], {}), '(f)\n', (1705, 1708), False, 'import pickle\n'), ((2133, 2149), 'streamlit.write', 'st.write', (['source'], {}), '(source)\n', (2141, 2149), True, 'import streamlit as st\n')]