Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,19 +10,30 @@ from Gradio_UI import GradioUI
|
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
def search_arxiv(query: str, max_results: int = 5) -> str:
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
url = f"http://export.arxiv.org/api/query?search_query={query}&max_results={max_results}"
|
15 |
response = requests.get(url)
|
16 |
|
17 |
if response.status_code == 200:
|
18 |
papers = []
|
19 |
for entry in response.text.split("<entry>")[1:max_results+1]:
|
20 |
-
title = entry.split("<title>")[1].split("</title>")[0]
|
21 |
-
|
22 |
-
|
23 |
papers.append(f"Title: {title}\nSummary: {summary}\nLink: {link}\n")
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
@tool
|
28 |
def summarize_text(text: str) -> str:
|
|
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
def search_arxiv(query: str, max_results: int = 5) -> str:
|
13 |
+
"""Searches arXiv for academic papers.
|
14 |
+
|
15 |
+
Args:
|
16 |
+
query (str): The topic or keywords to search for.
|
17 |
+
max_results (int): Number of papers to fetch.
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
str: A formatted list of found papers with titles, summaries, and links.
|
21 |
+
"""
|
22 |
url = f"http://export.arxiv.org/api/query?search_query={query}&max_results={max_results}"
|
23 |
response = requests.get(url)
|
24 |
|
25 |
if response.status_code == 200:
|
26 |
papers = []
|
27 |
for entry in response.text.split("<entry>")[1:max_results+1]:
|
28 |
+
title = entry.split("<title>")[1].split("</title>")[0].strip()
|
29 |
+
summary = entry.split("<summary>")[1].split("</summary>")[0].strip()
|
30 |
+
link = entry.split("<id>")[1].split("</id>")[0].strip()
|
31 |
papers.append(f"Title: {title}\nSummary: {summary}\nLink: {link}\n")
|
32 |
+
|
33 |
+
return "\n\n".join(papers)
|
34 |
+
|
35 |
+
return "No papers found."
|
36 |
+
|
37 |
|
38 |
@tool
|
39 |
def summarize_text(text: str) -> str:
|