from smolagents import DuckDuckGoSearchTool from smolagents import Tool import random from huggingface_hub import list_models # Initialize the DuckDuckGo search tool search_tool = DuckDuckGoSearchTool() class WeatherInfoTool(Tool): name = "weather_info" description = "Fetches dummy weather information for a given location." inputs = { "location": { "type": "string", "description": "The location to get weather information for." } } output_type = "string" def forward(self, location: str): # I removed the dummy weather data to use wttr.in to find real weather try: response = requests.get(f"https://wttr.in/{location}?format=3") return response.text if response.status_code == 200 else "Weather data unvailable." except Exception as e: return f"Error: {str(e)}" # I added the suggested "suggest_gala_outfit" tool # This should work in theory...... class GalaOutfitTool(Tool): name = "suggest_gala_outfit" description = "Suggests a gala outfit based on the current weather condition." inputs = {"condition": {"type": "string", "descrition": "The current weather (e.g.. rainy, cold, hot)."}} output_type = "string" def forward(self, condition: str): outfits = { "rainy": "A sleek waterproof trench coat over a navy blue tuxedo, paired with leather boots.", "cold": "A red velvet long gown with a fur coat or wool-blend suit", "hot": "A breathable silk dress or a lightweight linen dinner blazer.", "clear": "A classic black-tie outfit, tuxedo or evening gown." } return outfits.get(condition.lower(), "A black-tie formal look is always good") class HubStatsTool(Tool): name = "hub_stats" description = "Fetches the most downloaded model from a specific author on the Hugging Face Hub." inputs = { "author": { "type": "string", "description": "The username of the model author/organization to find models from." } } output_type = "string" def forward(self, author: str): try: # List models from the specified author, sorted by downloads models = list(list_models(author=author, sort="downloads", direction=-1, limit=1)) if models: model = models[0] return f"The most downloaded model by {author} is {model.id} with {model.downloads:,} downloads." else: return f"No models found for author {author}." except Exception as e: return f"Error fetching models for {author}: {str(e)}"