huggingfaceuser54 commited on
Commit
c60d75d
·
verified ·
1 Parent(s): 2d14636

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -1
app.py CHANGED
@@ -44,6 +44,48 @@ def get_current_time_in_timezone(timezone: str) -> str:
44
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
45
 
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  final_answer = FinalAnswerTool()
48
 
49
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
@@ -66,7 +108,7 @@ with open("prompts.yaml", 'r') as stream:
66
 
67
  agent = CodeAgent(
68
  model=model,
69
- tools=[final_answer,find_product,greet], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,
 
44
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
45
 
46
 
47
+
48
+ @tool
49
+
50
+
51
+ def get_latest_ai_agent_arxiv_papers(num_papers=5):
52
+ """
53
+ Searches arXiv for the latest research papers on AI agents and retrieves
54
+ the specified number of results.
55
+
56
+ Args:
57
+ num_papers: The number of papers to retrieve (default: 5).
58
+
59
+ Returns:
60
+ A list of dictionaries, where each dictionary represents a paper and
61
+ contains its title, authors, and URL. Returns an empty list if any errors occur.
62
+ Prints informative messages to the console during the search.
63
+ """
64
+ import arxiv
65
+
66
+ try:
67
+ search = arxiv.Search(
68
+ query="AI agents", # Your search term
69
+ max_results=num_papers,
70
+ sort_by=arxiv.SortCriterion.SubmittedDate # Sort by submission date for latest
71
+ )
72
+
73
+ papers = []
74
+ for result in search.results():
75
+ paper_info = {
76
+ "title": result.title,
77
+ "authors": ", ".join([author.name for author in result.authors]), # Nicer author format
78
+ "url": result.pdf_url,
79
+ "date": result.published.date(), # Get the date part of the datetime object
80
+ "abstract": result.summary
81
+ }
82
+ papers.append(paper_info)
83
+ return papers
84
+
85
+ except Exception as e:
86
+ print(f"An error occurred during the arXiv search: {e}")
87
+ return []
88
+
89
  final_answer = FinalAnswerTool()
90
 
91
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
 
108
 
109
  agent = CodeAgent(
110
  model=model,
111
+ tools=[final_answer,find_product,greet,get_latest_ai_agent_arxiv_papers], ## add your tools here (don't remove final answer)
112
  max_steps=6,
113
  verbosity_level=1,
114
  grammar=None,