Spaces:
Sleeping
Sleeping
Update tools.py
Browse filesAdded latest_news_tool
tools.py
CHANGED
|
@@ -110,3 +110,25 @@ hub_stats_tool = HubStatsTool()
|
|
| 110 |
|
| 111 |
# Example usage
|
| 112 |
print(hub_stats_tool("facebook")) # Example: Get the most downloaded model by Facebook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
# Example usage
|
| 112 |
print(hub_stats_tool("facebook")) # Example: Get the most downloaded model by Facebook
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class LatestNewsTool(Tool):
|
| 117 |
+
name = "latest_news_tool"
|
| 118 |
+
description = "Fetches the latest news related to a specific topic using DuckDuckGoSearchTool"
|
| 119 |
+
inputs = {
|
| 120 |
+
"topic":{
|
| 121 |
+
"type":"string",
|
| 122 |
+
"description":"The topic for which the latest news is needed"
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
output_type = "string"
|
| 126 |
+
|
| 127 |
+
def __init__(self):
|
| 128 |
+
self.search_tool = DuckDuckGoSearchTool()
|
| 129 |
+
|
| 130 |
+
def forward(self, topic: str):
|
| 131 |
+
results = self.search_tool.forward(f"{topic} latest news")
|
| 132 |
+
return results
|
| 133 |
+
|
| 134 |
+
|