Update app.py
Browse files
app.py
CHANGED
@@ -543,6 +543,7 @@ def safe_rerun():
|
|
543 |
if hasattr(st, "experimental_rerun"):
|
544 |
st.experimental_rerun()
|
545 |
|
|
|
546 |
def main():
|
547 |
# Initialize session state on first run
|
548 |
if 'initialized' not in st.session_state:
|
@@ -589,7 +590,7 @@ def main():
|
|
589 |
st.session_state.google_creds = creds
|
590 |
st.write(msg)
|
591 |
|
592 |
-
#
|
593 |
if mode == "Manual URL":
|
594 |
st.header("Manual URL Mode")
|
595 |
url = st.text_input("Enter URL", placeholder="https://example.com", key="url_input")
|
@@ -607,9 +608,6 @@ def main():
|
|
607 |
sublink_limit=int(max_sublinks),
|
608 |
timeout=int(sublink_timeout)
|
609 |
)
|
610 |
-
if files:
|
611 |
-
st.session_state.discovered_files = files
|
612 |
-
st.session_state.current_url = url
|
613 |
return files
|
614 |
except Exception as e:
|
615 |
st.error(f"Error during deep search: {str(e)}")
|
@@ -617,6 +615,9 @@ def main():
|
|
617 |
|
618 |
files = asyncio.run(run_deep_search())
|
619 |
if files:
|
|
|
|
|
|
|
620 |
st.success(f"Found {len(files)} files!")
|
621 |
|
622 |
# File selection block 1
|
@@ -663,6 +664,7 @@ def main():
|
|
663 |
file_info = files[idx]
|
664 |
status_text.text(f"Downloading {file_info['filename']}... ({i+1}/{len(selected_files)})")
|
665 |
progress_bar.progress(progress)
|
|
|
666 |
path = await dm.download_file(file_info, download_dir, url)
|
667 |
if path:
|
668 |
downloaded_paths.append(path)
|
@@ -694,7 +696,7 @@ def main():
|
|
694 |
else:
|
695 |
st.warning("No files found.")
|
696 |
|
697 |
-
# File selection block 2 (if files
|
698 |
if st.session_state.discovered_files:
|
699 |
files = st.session_state.discovered_files
|
700 |
st.success(f"Found {len(files)} files!")
|
@@ -783,7 +785,7 @@ def main():
|
|
783 |
if urls:
|
784 |
st.success(f"Found {len(urls)} results!")
|
785 |
for i, url in enumerate(urls, 1):
|
786 |
-
with st.expander(f"Result {i}: {url}", expanded=i==1):
|
787 |
if st.button(f"Deep Search Result {i}", key=f"deep_search_result_{i}"):
|
788 |
files = await dm.deep_search(
|
789 |
url=url,
|
@@ -826,6 +828,7 @@ def main():
|
|
826 |
except Exception as e:
|
827 |
st.error(f"Error summarizing PDF: {e}")
|
828 |
|
|
|
829 |
if __name__ == "__main__":
|
830 |
try:
|
831 |
main()
|
|
|
543 |
if hasattr(st, "experimental_rerun"):
|
544 |
st.experimental_rerun()
|
545 |
|
546 |
+
|
547 |
def main():
|
548 |
# Initialize session state on first run
|
549 |
if 'initialized' not in st.session_state:
|
|
|
590 |
st.session_state.google_creds = creds
|
591 |
st.write(msg)
|
592 |
|
593 |
+
# Manual URL mode
|
594 |
if mode == "Manual URL":
|
595 |
st.header("Manual URL Mode")
|
596 |
url = st.text_input("Enter URL", placeholder="https://example.com", key="url_input")
|
|
|
608 |
sublink_limit=int(max_sublinks),
|
609 |
timeout=int(sublink_timeout)
|
610 |
)
|
|
|
|
|
|
|
611 |
return files
|
612 |
except Exception as e:
|
613 |
st.error(f"Error during deep search: {str(e)}")
|
|
|
615 |
|
616 |
files = asyncio.run(run_deep_search())
|
617 |
if files:
|
618 |
+
# Save all discovered files even if duplicated
|
619 |
+
st.session_state.discovered_files = files
|
620 |
+
st.session_state.current_url = url
|
621 |
st.success(f"Found {len(files)} files!")
|
622 |
|
623 |
# File selection block 1
|
|
|
664 |
file_info = files[idx]
|
665 |
status_text.text(f"Downloading {file_info['filename']}... ({i+1}/{len(selected_files)})")
|
666 |
progress_bar.progress(progress)
|
667 |
+
# In DownloadManager.download_file(), consider adding a fallback to requests if needed.
|
668 |
path = await dm.download_file(file_info, download_dir, url)
|
669 |
if path:
|
670 |
downloaded_paths.append(path)
|
|
|
696 |
else:
|
697 |
st.warning("No files found.")
|
698 |
|
699 |
+
# File selection block 2 (if files have already been discovered)
|
700 |
if st.session_state.discovered_files:
|
701 |
files = st.session_state.discovered_files
|
702 |
st.success(f"Found {len(files)} files!")
|
|
|
785 |
if urls:
|
786 |
st.success(f"Found {len(urls)} results!")
|
787 |
for i, url in enumerate(urls, 1):
|
788 |
+
with st.expander(f"Result {i}: {url}", expanded=i == 1):
|
789 |
if st.button(f"Deep Search Result {i}", key=f"deep_search_result_{i}"):
|
790 |
files = await dm.deep_search(
|
791 |
url=url,
|
|
|
828 |
except Exception as e:
|
829 |
st.error(f"Error summarizing PDF: {e}")
|
830 |
|
831 |
+
|
832 |
if __name__ == "__main__":
|
833 |
try:
|
834 |
main()
|