hackmebroo commited on
Commit
48d2b67
·
verified ·
1 Parent(s): fdd67c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -16
app.py CHANGED
@@ -9,24 +9,21 @@ from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def most_common_letter(text: str, _: str) -> str:
13
- """Finds the most common alphabet letter in the given text (case-insensitive).
14
  Args:
15
- text: The input text to analyze.
16
- _: Unused second argument.
17
  """
18
- text = text.lower()
19
- frequency = {}
20
-
21
- for char in text:
22
- if 'a' <= char <= 'z':
23
- frequency[char] = frequency.get(char, 0) + 1
24
-
25
- if not frequency:
26
- return "No alphabet letters found in the input."
27
-
28
- most_common = max(frequency.items(), key=lambda x: x[1])
29
- return f"The most common letter is '{most_common[0]}' which appears {most_common[1]} time(s)."
30
 
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str:
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def days_between_dates(date1: str, date2: str) -> str:
13
+ """计算两个日期相差多少天 (YYYY-MM-DD).
14
  Args:
15
+ date1: 第一个日期.
16
+ date2: 第二个日期.
17
  """
18
+ from datetime import datetime
19
+ fmt = "%Y-%m-%d"
20
+ try:
21
+ d1 = datetime.strptime(date1, fmt)
22
+ d2 = datetime.strptime(date2, fmt)
23
+ delta = abs((d2 - d1).days)
24
+ return f"There are {delta} day(s) between {date1} and {date2}."
25
+ except Exception as e:
26
+ return f"Error: {str(e)}"
 
 
 
27
 
28
  @tool
29
  def get_current_time_in_timezone(timezone: str) -> str: