Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 13 |
-
"""
|
| 14 |
Args:
|
| 15 |
-
|
| 16 |
-
|
| 17 |
"""
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
return "
|
| 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:
|