File size: 2,261 Bytes
afe2831
b2389a0
 
79f852c
afe2831
79f852c
 
afe2831
bcb1873
afe2831
d26938f
539c396
7ad917c
afe2831
f61c5df
 
 
 
 
 
 
 
 
 
 
ea36138
f61c5df
 
 
 
 
 
 
 
 
 
 
b2389a0
f61c5df
f0beecf
afe2831
b2389a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c23ae4e
4171bd5
 
 
 
0d63432
4171bd5
 
 
 
 
 
 
 
 
 
 
 
 
c23ae4e
b2389a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import requests
import datetime

from transformers import Tool


class RandomCharatorGeneratorTool(Tool):
    name = "random_character"
    description = "This tool generates a random character. Returns json."

    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 
            <span id="time"></span>
          </div>
          <script>
          alert()
            function updateTime() {
              var now = new Date();
              var hours = now.getHours();
              var minutes = now.getMinutes();
              var seconds = now.getSeconds();
              
              document.getElementById('time').textContent = hours + ':' + minutes + ':' + seconds;
            }
            
            window.addEventListener('load', function() {
              setInterval(updateTime, 1000); // Update every second
            });
          </script>
        '''
        return now.strftime("%Y-%m-%d %H:%M:%S")