Spaces:
Sleeping
Sleeping
from smolagents import Tool | |
from typing import Any, Optional | |
class SimpleTool(Tool): | |
name = "schedule_sleep" | |
description = "Creates a sleep schedule based on desired hours." | |
inputs = {"hours":{"type":"integer","description":"Number of sleep hours desired (6-9 recommended)"}} | |
output_type = "string" | |
def forward(self, hours: int) -> str: | |
""" | |
Creates a sleep schedule based on desired hours. | |
Args: | |
hours: Number of sleep hours desired (6-9 recommended) | |
""" | |
if not 4 <= hours <= 12: | |
return "Please provide a reasonable sleep duration (4-12 hours)" | |
bedtime = "10:00 PM" | |
wake_time = f"{(22 + hours - 24) if (22 + hours) > 24 else (22 + hours)}:00 {'AM' if (22 + hours) <= 24 else 'AM'}" | |
return f"For {hours} hours of sleep:\nBedtime: {bedtime}\nWake-up: {wake_time}\nSleep cycles: {hours // 1.5} (approx.)" |