neyul18 commited on
Commit
ba2e72a
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
 
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
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: