Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,24 +8,24 @@ from smolagents import CodeAgent, HfApiModel, tool
|
|
8 |
@tool
|
9 |
def fetch_latest_arxiv_papers(keywords: list, num_results: int = 3) -> list:
|
10 |
"""
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
keywords (list): A list of keywords to
|
15 |
-
num_results (int): The number of papers to fetch
|
16 |
|
17 |
Returns:
|
18 |
-
list: A list of dictionaries, each
|
19 |
-
-
|
20 |
-
-
|
21 |
-
-
|
22 |
-
-
|
23 |
-
-
|
24 |
"""
|
25 |
try:
|
26 |
print(f"DEBUG: Searching arXiv papers with keywords: {keywords}") # Debug input
|
27 |
|
28 |
-
#
|
29 |
query = "+AND+".join([f"all:{kw}" for kw in keywords])
|
30 |
query_encoded = urllib.parse.quote(query) # Encode spaces and special characters
|
31 |
|
@@ -49,7 +49,7 @@ def fetch_latest_arxiv_papers(keywords: list, num_results: int = 3) -> list:
|
|
49 |
|
50 |
except Exception as e:
|
51 |
print(f"ERROR: {str(e)}") # Debug errors
|
52 |
-
return [f"Error fetching research papers: {str(e)}"]
|
53 |
|
54 |
model = HfApiModel(
|
55 |
max_tokens=2096,
|
|
|
8 |
@tool
|
9 |
def fetch_latest_arxiv_papers(keywords: list, num_results: int = 3) -> list:
|
10 |
"""
|
11 |
+
Fetch the latest research papers from arXiv.
|
12 |
|
13 |
+
Parameters:
|
14 |
+
keywords (list of str): A list of search keywords. Each keyword is used to filter relevant papers.
|
15 |
+
num_results (int): The maximum number of research papers to fetch. Default is 3.
|
16 |
|
17 |
Returns:
|
18 |
+
list of dict: A list of dictionaries, where each dictionary contains:
|
19 |
+
- title (str): The title of the research paper.
|
20 |
+
- authors (str): The authors of the paper.
|
21 |
+
- year (str): The publication year.
|
22 |
+
- abstract (str): A summary of the research paper.
|
23 |
+
- link (str): A direct link to the paper on arXiv.
|
24 |
"""
|
25 |
try:
|
26 |
print(f"DEBUG: Searching arXiv papers with keywords: {keywords}") # Debug input
|
27 |
|
28 |
+
#Properly format query with +AND+ for multiple keywords
|
29 |
query = "+AND+".join([f"all:{kw}" for kw in keywords])
|
30 |
query_encoded = urllib.parse.quote(query) # Encode spaces and special characters
|
31 |
|
|
|
49 |
|
50 |
except Exception as e:
|
51 |
print(f"ERROR: {str(e)}") # Debug errors
|
52 |
+
return [{"error": f"Error fetching research papers: {str(e)}"}]
|
53 |
|
54 |
model = HfApiModel(
|
55 |
max_tokens=2096,
|