bohmian commited on
Commit
88dfb76
1 Parent(s): 8758019

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -629,6 +629,7 @@ if page == "Scrape or Upload Own Docs":
629
 
630
  submit_upload_pdf = False
631
  submit_scrape_web = False
 
632
 
633
  # form for user to configure pdf loading options
634
  if option == options[0]:
@@ -640,7 +641,7 @@ if page == "Scrape or Upload Own Docs":
640
  with open(temp_file, "wb") as file:
641
  file.write(uploaded_pdf.getvalue())
642
  pdf_filename, = uploaded_pdf.name
643
- submit_upload_pdf = st.form_submit_button(label='Submit')
644
 
645
  # form for user to configure web scraping for duckduckgo
646
  if option == options[1]:
@@ -655,17 +656,22 @@ if page == "Scrape or Upload Own Docs":
655
  "Search Term",
656
  value = f"{country_scrape_upload} sustainability esg newest updated public policy document government",
657
  )
658
- submit_scrape_web = st.form_submit_button(label='Submit')
 
 
 
 
 
 
659
 
660
  if (submit_upload_pdf | submit_scrape_web):
661
  if submit_upload_pdf:
662
  with st.spinner('Generating documents from PDF...'):
663
  all_documents = pdf_loader_local(pdf_filename, country_scrape_upload)
664
 
665
- if submit_scrape_web:
666
  with st.spinner('Scraping web using Duck Duck Go search...'):
667
- all_links, df_links = duckduckgo_scrape(country_scrape_upload, search_term, n_search_results)
668
- st.write(df_links)
669
  with st.spinner('Generating documents from web search results...'):
670
  all_documents = process_links_load_documents(all_links)
671
 
 
629
 
630
  submit_upload_pdf = False
631
  submit_scrape_web = False
632
+ submit_scrape_vector_store = False
633
 
634
  # form for user to configure pdf loading options
635
  if option == options[0]:
 
641
  with open(temp_file, "wb") as file:
642
  file.write(uploaded_pdf.getvalue())
643
  pdf_filename, = uploaded_pdf.name
644
+ submit_upload_pdf = st.form_submit_button(label='Upload and Create Vector Store')
645
 
646
  # form for user to configure web scraping for duckduckgo
647
  if option == options[1]:
 
656
  "Search Term",
657
  value = f"{country_scrape_upload} sustainability esg newest updated public policy document government",
658
  )
659
+ submit_scrape_web = st.form_submit_button(label='Scrape Web for Results')
660
+
661
+ if submit_scrape_web:
662
+ with st.form(key='scrape_web_form2'):
663
+ st.write(f"Results from Web Scrape")
664
+ st.table(df_links)
665
+ submit_scrape_vector_store = st.form_submit_button(label='Create Vector Store from Search Results')
666
 
667
  if (submit_upload_pdf | submit_scrape_web):
668
  if submit_upload_pdf:
669
  with st.spinner('Generating documents from PDF...'):
670
  all_documents = pdf_loader_local(pdf_filename, country_scrape_upload)
671
 
672
+ if submit_scrape_vector_store:
673
  with st.spinner('Scraping web using Duck Duck Go search...'):
674
+ all_links, df_links = duckduckgo_scrape(country_scrape_upload, search_term, n_search_results)
 
675
  with st.spinner('Generating documents from web search results...'):
676
  all_documents = process_links_load_documents(all_links)
677