mo-ali-nlp commited on
Commit
7348fc8
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files

I added a custom tool to search news headlines using the DuckDuckGo tool

Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -18,6 +18,19 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def get_news_headlines(headline: str)-> str:
23
+ """A tool that fetches the most recent headlines
24
+ Args:
25
+ headline: A string representing the latest news headlines
26
+ """
27
+ try:
28
+ hl = DuckDuckGoSearchTool()
29
+ results = hl.run(f"{topic} news")
30
+ return f"The current news headlines are {results}"
31
+ except Exception as e:
32
+ return f"Error fetching news headlines"
33
+
34
  @tool
35
  def get_current_time_in_timezone(timezone: str) -> str:
36
  """A tool that fetches the current local time in a specified timezone.