Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,23 +27,21 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 27 |
#Following my creation.
|
| 28 |
@tool
|
| 29 |
def get_fun_fact(topic: str) -> str:
|
| 30 |
-
"""Finds
|
| 31 |
Args:
|
| 32 |
-
topic: The topic to search for
|
| 33 |
Returns:
|
| 34 |
-
A string reporting a
|
| 35 |
"""
|
| 36 |
try:
|
| 37 |
search_tool=DuckDuckGoSearchTool(max_results=1)
|
| 38 |
-
|
| 39 |
-
if
|
| 40 |
-
|
| 41 |
-
fun_fact=visit_web_page.forward(url)
|
| 42 |
-
return f"Here's a fun fact about {topic}: {fun_fact[:300]}"
|
| 43 |
else:
|
| 44 |
-
return f"Sorry, I could not find
|
| 45 |
except Exception as e:
|
| 46 |
-
return f"Sorry, I couldn't find
|
| 47 |
|
| 48 |
final_answer = FinalAnswerTool()
|
| 49 |
|
|
|
|
| 27 |
#Following my creation.
|
| 28 |
@tool
|
| 29 |
def get_fun_fact(topic: str) -> str:
|
| 30 |
+
"""Finds an URL where I can read news about a given topic using DuckDuckGo.
|
| 31 |
Args:
|
| 32 |
+
topic: The topic to search for news.
|
| 33 |
Returns:
|
| 34 |
+
A string reporting an url of a news related to the topic or an error message.
|
| 35 |
"""
|
| 36 |
try:
|
| 37 |
search_tool=DuckDuckGoSearchTool(max_results=1)
|
| 38 |
+
results = search_tool.forward(f"Today news about {topic}")
|
| 39 |
+
if results:
|
| 40 |
+
return f"Here's an url where you can read news about {topic}: {results}"
|
|
|
|
|
|
|
| 41 |
else:
|
| 42 |
+
return f"Sorry, I could not find any news about {topic}."
|
| 43 |
except Exception as e:
|
| 44 |
+
return f"Sorry, I couldn't find any news. Error: {e}"
|
| 45 |
|
| 46 |
final_answer = FinalAnswerTool()
|
| 47 |
|