Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,13 +10,13 @@ from tools.final_answer import FinalAnswerTool
|
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
@tool
|
| 13 |
-
def search_articles(
|
| 14 |
"""
|
| 15 |
Searches for academic articles on arxiv.org using a given search term, retrieves
|
| 16 |
results within a given range, and saves the output as a Markdown file.
|
| 17 |
|
| 18 |
Args:
|
| 19 |
-
|
| 20 |
start (int): The starting index of the search results (used for pagination).
|
| 21 |
end (int): The number of articles to retrieve from the API.
|
| 22 |
output_md (str, optional): The name of the output Markdown file. Defaults to "arxiv_articles.md".
|
|
@@ -31,8 +31,8 @@ def search_articles(text2search: str, start: int, end: int, output_md: str = "ar
|
|
| 31 |
try:
|
| 32 |
# Construct the ArXiv API query
|
| 33 |
search_url = (
|
| 34 |
-
f"http://export.arxiv.org/api/query?search_query=all:{
|
| 35 |
-
f"&start={start}&max_results=
|
| 36 |
)
|
| 37 |
|
| 38 |
response = requests.get(search_url)
|
|
@@ -58,11 +58,11 @@ def search_articles(text2search: str, start: int, end: int, output_md: str = "ar
|
|
| 58 |
articles.append(f"### [{title}]({link})\n**Published Date:** {published_date}\n")
|
| 59 |
|
| 60 |
if not articles:
|
| 61 |
-
return f"No articles found for '{
|
| 62 |
|
| 63 |
# Save results to a Markdown file
|
| 64 |
with open(output_md, "w", encoding="utf-8") as md_file:
|
| 65 |
-
md_file.write(f"# ArXiv Articles on '{
|
| 66 |
md_file.writelines("\n".join(articles))
|
| 67 |
|
| 68 |
return f"Markdown file created: {os.path.abspath(output_md)}"
|
|
|
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
@tool
|
| 13 |
+
def search_articles(search_term: str, start: int, end: int, output_md: str = "arxiv_articles.md") -> str:
|
| 14 |
"""
|
| 15 |
Searches for academic articles on arxiv.org using a given search term, retrieves
|
| 16 |
results within a given range, and saves the output as a Markdown file.
|
| 17 |
|
| 18 |
Args:
|
| 19 |
+
search_term (str): The keyword or phrase to search for in ArXiv articles.
|
| 20 |
start (int): The starting index of the search results (used for pagination).
|
| 21 |
end (int): The number of articles to retrieve from the API.
|
| 22 |
output_md (str, optional): The name of the output Markdown file. Defaults to "arxiv_articles.md".
|
|
|
|
| 31 |
try:
|
| 32 |
# Construct the ArXiv API query
|
| 33 |
search_url = (
|
| 34 |
+
f"http://export.arxiv.org/api/query?search_query=all:{search_term}"
|
| 35 |
+
f"&start={start}&max_results={end}&sortBy=submittedDate&sortOrder=descending"
|
| 36 |
)
|
| 37 |
|
| 38 |
response = requests.get(search_url)
|
|
|
|
| 58 |
articles.append(f"### [{title}]({link})\n**Published Date:** {published_date}\n")
|
| 59 |
|
| 60 |
if not articles:
|
| 61 |
+
return f"No articles found for '{search_term}'."
|
| 62 |
|
| 63 |
# Save results to a Markdown file
|
| 64 |
with open(output_md, "w", encoding="utf-8") as md_file:
|
| 65 |
+
md_file.write(f"# ArXiv Articles on '{search_term}'\n\n")
|
| 66 |
md_file.writelines("\n".join(articles))
|
| 67 |
|
| 68 |
return f"Markdown file created: {os.path.abspath(output_md)}"
|