Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,14 +9,26 @@ 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 |
-
"""A tool that does nothing yet
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
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 calculate_yen_by_usd(usd: str, exchange_rate: int) -> str: #it's import to specify the return type
|
13 |
+
"""Calculates the equivalent amount in Japanese Yen given USD and the exchange rate.
|
|
|
14 |
Args:
|
15 |
+
usd: The amount of USD to convert (as a string).
|
16 |
+
exchange_rate: The exchange rate (JPY per USD).
|
17 |
+
Returns:
|
18 |
+
A string representing the total Yen after exchange, or an error message if input is invalid.
|
19 |
"""
|
20 |
+
try:
|
21 |
+
usd_amount = float(usd) # Convert USD input to a float
|
22 |
+
if usd_amount < 0:
|
23 |
+
return "USD amount must be non-negative."
|
24 |
+
|
25 |
+
if exchange_rate <= 0: # Check for invalid exchange rate
|
26 |
+
return "Exchange rate must be positive."
|
27 |
+
|
28 |
+
yen_amount = usd_amount * exchange_rate
|
29 |
+
return str(int(yen_amount)) # Return the Yen amount as a string (integer part)
|
30 |
+
except ValueError:
|
31 |
+
return "Invalid USD amount. Please enter a numerical value."
|
32 |
|
33 |
@tool
|
34 |
def get_current_time_in_timezone(timezone: str) -> str:
|