pdx97 commited on
Commit
21a2c38
·
verified ·
1 Parent(s): b80cbf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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
- Fetches the latest research papers from arXiv based on provided keywords.
12
 
13
- Args:
14
- keywords (list): A list of keywords to search for relevant papers.
15
- num_results (int): The number of papers to fetch (default is 3).
16
 
17
  Returns:
18
- list: A list of dictionaries, each containing:
19
- - "title": The paper title
20
- - "authors": A string of authors
21
- - "year": Year of publication
22
- - "abstract": Summary of the paper
23
- - "link": URL to the full paper
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,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,