Spaces:
Sleeping
Sleeping
Update tools/get_news.py
Browse files- tools/get_news.py +5 -3
tools/get_news.py
CHANGED
@@ -3,7 +3,7 @@ from smolagents.tools import Tool
|
|
3 |
|
4 |
class GetNewsTool(Tool):
|
5 |
name = "Get_News"
|
6 |
-
description = "Fetches the latest NYTimes RSS feed and returns the headlines of the most recent 5 stories."
|
7 |
inputs = {} # This tool does not require any inputs.
|
8 |
output_type = "string"
|
9 |
|
@@ -24,6 +24,8 @@ class GetNewsTool(Tool):
|
|
24 |
if not feed.entries:
|
25 |
raise Exception("No entries found in the feed.")
|
26 |
latest_entries = feed.entries[:self.max_results]
|
27 |
-
|
28 |
-
result = "## NYTimes Latest Headlines\n\n" + "\n".join(
|
|
|
|
|
29 |
return result
|
|
|
3 |
|
4 |
class GetNewsTool(Tool):
|
5 |
name = "Get_News"
|
6 |
+
description = "Fetches the latest NYTimes RSS feed and returns the headlines and URLs of the most recent 5 stories."
|
7 |
inputs = {} # This tool does not require any inputs.
|
8 |
output_type = "string"
|
9 |
|
|
|
24 |
if not feed.entries:
|
25 |
raise Exception("No entries found in the feed.")
|
26 |
latest_entries = feed.entries[:self.max_results]
|
27 |
+
# Format each entry with its headline as a clickable link pointing to the URL.
|
28 |
+
result = "## NYTimes Latest Headlines and URLs\n\n" + "\n".join(
|
29 |
+
f"- [{entry.title}]({entry.link})" for entry in latest_entries
|
30 |
+
)
|
31 |
return result
|