Luis commited on
Commit
d806e9c
·
verified ·
1 Parent(s): 72746e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -11,17 +11,29 @@ from Gradio_UI import GradioUI
11
 
12
  # Belo is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
- def time_left_for_event(arg1:str, arg2:int)-> str: #it's import to specify the return type
15
  """A tool that calculates the time left for a certain event, and returns in a very convenient way the time between today and that events date
16
  Args:
17
- arg1: the event name, this can be wedding, birthday, trip, travel, work event, reunion, etc..
18
- arg2: the day of that event in calendar time
 
 
 
19
  """
20
 
21
- local_time = datetime.datetime.now()
22
- future_time = datetime.datetime(arg2)
23
- time_between = local_time - future_time
24
- return f"you have {time_between} before the {arg1}"
 
 
 
 
 
 
 
 
 
25
 
26
 
27
 
 
11
 
12
  # Belo is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
+ def time_left_for_event(event:str, date:str)-> str: #it's import to specify the return type
15
  """A tool that calculates the time left for a certain event, and returns in a very convenient way the time between today and that events date
16
  Args:
17
+ event: the event name, this can be wedding, birthday, trip, travel, work event, reunion, etc..
18
+ sate: the day of that event in calendar time
19
+
20
+ Returns:
21
+ A string telling the user how many months, weeks or days are left before the event date
22
  """
23
 
24
+ try:
25
+ # Calculate Todays date
26
+ today = datetime.datetime.now()
27
+ # calculate the events date difference
28
+ difference = event_date - today
29
+ # Convert the difference into months, weeks or days
30
+ if difference < 7:
31
+ ans = f"{difference} days"
32
+ elif difference > 7:
33
+ ans = f"{difference} weeks"
34
+ return f"you have the following time: {ans}"
35
+ except Exception as e:
36
+ return f"Error: {e}"
37
 
38
 
39