Spaces:
Sleeping
Sleeping
Update tools.py
Browse files
tools.py
CHANGED
|
@@ -54,3 +54,27 @@ class HubStatsTool(Tool):
|
|
| 54 |
except Exception as e:
|
| 55 |
return f"Error fetching models for {author}: {str(e)}"
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
return f"Error fetching models for {author}: {str(e)}"
|
| 56 |
|
| 57 |
+
from smolagents import Tool
|
| 58 |
+
from huggingface_hub import list_models
|
| 59 |
+
|
| 60 |
+
class NewsTool(Tool):
|
| 61 |
+
name = "news"
|
| 62 |
+
description = "Search for the latest news on a specific topic."
|
| 63 |
+
inputs = {
|
| 64 |
+
"author": {
|
| 65 |
+
"type": "string",
|
| 66 |
+
"description": "The topic on which the user wants the latest news"
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
output_type = "string"
|
| 70 |
+
|
| 71 |
+
def forward(self, author: str):
|
| 72 |
+
search_tool = DuckDuckGoSearchTool()
|
| 73 |
+
# Example usage
|
| 74 |
+
results = search_tool(f"What are the latest news on {author}?")
|
| 75 |
+
return f"Voici les dernières informations sur {author} : {str(results)}"
|
| 76 |
+
# Initialize the tool
|
| 77 |
+
news_tool = NewsTool()
|
| 78 |
+
|
| 79 |
+
# Example usage
|
| 80 |
+
print(news_tool("CAPES"))
|