Gas96 commited on
Commit
d1abb3b
·
verified ·
1 Parent(s): b928ede

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
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 a fun fact about a given topic using DuckDuckGo.
31
  Args:
32
- topic: The topic to search for a fun fact about.
33
  Returns:
34
- A string reporting a fun fact related to the topic or an error message.
35
  """
36
  try:
37
  search_tool=DuckDuckGoSearchTool(max_results=1)
38
- url = search_tool.forward(f"fun fact about {topic}")
39
- if url:
40
- visit_web_page=VisitWebpageTool()
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 a fun fact about {topic}."
45
  except Exception as e:
46
- return f"Sorry, I couldn't find a fun fact. Error: {e}"
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