Files changed (1) hide show
  1. tools.py +14 -3
tools.py CHANGED
@@ -4,9 +4,21 @@ import random
4
  from huggingface_hub import list_models
5
 
6
 
7
- # Initialize the DuckDuckGo search tool
8
- #search_tool = DuckDuckGoSearchTool()
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  class WeatherInfoTool(Tool):
12
  name = "weather_info"
@@ -53,4 +65,3 @@ class HubStatsTool(Tool):
53
  return f"No models found for author {author}."
54
  except Exception as e:
55
  return f"Error fetching models for {author}: {str(e)}"
56
-
 
4
  from huggingface_hub import list_models
5
 
6
 
 
 
7
 
8
+ class SearchNews(Tool):
9
+ name = "search_news"
10
+ description = "Browses the web for the latest news on some subject to discuss."
11
+ inputs = {
12
+ "subject": "Key words on the subject to be searched."
13
+ }
14
+ output_type = "string"
15
+ def forward(self, subject: str) -> str:
16
+ search_tool = DuckDuckGoSearchTool(max_results=5)
17
+ try:
18
+ results = search_tool(subject + "news")
19
+ return results
20
+ except Exception as e:
21
+ return "No news found: " + e
22
 
23
  class WeatherInfoTool(Tool):
24
  name = "weather_info"
 
65
  return f"No models found for author {author}."
66
  except Exception as e:
67
  return f"Error fetching models for {author}: {str(e)}"