import requests import datetime from transformers import Tool class TimeTellerTool(Tool): name = "what_time_is_it" description = "This tool tells the current time. What time is it?" inputs = ["text"] # Adding an empty list for inputs outputs = ["html"] def __init__(self, device=None, **hub_kwargs) -> None: #if not is_accelerate_available(): # raise ImportError("Accelerate should be installed in order to use tools.") super().__init__() self.device = device self.pipeline = None self.hub_kwargs = hub_kwargs def setup(self): #if self.device is None: # self.device = get_default_device() #self.pipeline = DiffusionPipeline.from_pretrained(self.default_checkpoint) #self.pipeline.scheduler = DPMSolverMultistepScheduler.from_config(self.pipeline.scheduler.config) #self.pipeline.to(self.device) #if self.device.type == "cuda": # self.pipeline.to(torch_dtype=torch.float16) self.is_initialized = True def __call__(self, input:str="", *args, **kwargs): # Get the current date and time now = datetime.datetime.now() # Create a datetime object representing the current date and time # Display a message indicating what is being printed print("Current date and time : ") # Print the current date and time in a specific format print(now.strftime("%Y-%m-%d %H:%M:%S")) text = ''' Current time ''' return now.strftime("%Y-%m-%d %H:%M:%S")