Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,24 +10,24 @@ from src.Surveyor import Surveyor
|
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
-
def get_surveyor_instance(_print_fn, _survey_print_fn):
|
| 14 |
with st.spinner('Loading The-Researcher ...'):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
return Surveyor(print_fn=_print_fn, survey_print_fn=_survey_print_fn, high_gpu=True, **dir_args)
|
| 22 |
|
| 23 |
|
| 24 |
def run_survey(_print_fn, _survey_print_fn, download_placeholder, research_keywords=None, arxiv_ids=None, max_search=None, num_papers=None):
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
def show_survey_download(zip_file_name, survey_file_name, download_placeholder):
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
+
def get_surveyor_instance(td, _print_fn, _survey_print_fn):
|
| 14 |
with st.spinner('Loading The-Researcher ...'):
|
| 15 |
+
survey_root = Path(td)
|
| 16 |
+
dir_args = {f'{dname}_dir': survey_root / dname for dname in ['pdf', 'txt', 'img', 'tab', 'dump']}
|
| 17 |
+
for d in dir_args.values():
|
| 18 |
+
d.mkdir(exist_ok=True, parents=True)
|
| 19 |
+
dir_args = {k: str(v.resolve()) for k, v in dir_args.items()}
|
| 20 |
+
return Surveyor(print_fn=_print_fn, survey_print_fn=_survey_print_fn, high_gpu=True, **dir_args)
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
def run_survey(_print_fn, _survey_print_fn, download_placeholder, research_keywords=None, arxiv_ids=None, max_search=None, num_papers=None):
|
| 24 |
+
with tempfile.TemporaryDirectory() as td:
|
| 25 |
+
zip_file_name, survey_file_name = get_surveyor_instance(td, _print_fn, _survey_print_fn).survey(research_keywords,
|
| 26 |
+
arxiv_ids,
|
| 27 |
+
max_search=max_search,
|
| 28 |
+
num_papers=num_papers
|
| 29 |
+
)
|
| 30 |
+
show_survey_download(zip_file_name, survey_file_name, download_placeholder)
|
| 31 |
|
| 32 |
|
| 33 |
def show_survey_download(zip_file_name, survey_file_name, download_placeholder):
|