gokceKy commited on
Commit
73df126
·
verified ·
1 Parent(s): 76fe2d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -10,20 +10,20 @@ from Gradio_UI import GradioUI
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
  def calculator(arg1: int, arg2: str, arg3: int) -> int:
13
- '''
14
- A simple calculator that performs basic arithmetic operations.
15
 
16
  Args:
17
- arg1 (int): The first operand, an integer number.
18
- arg2 (str): The operator, which can be '+', '-', '*' or '/'.
19
- arg3 (int): The second operand, an integer number.
20
 
21
  Returns:
22
  int: The result of the calculation.
23
 
24
  Raises:
25
  ValueError: If an invalid operator is provided.
26
- '''
27
  if arg2 == "+":
28
  return arg1 + arg3
29
  elif arg2 == "-":
@@ -31,9 +31,12 @@ def calculator(arg1: int, arg2: str, arg3: int) -> int:
31
  elif arg2 == "*":
32
  return arg1 * arg3
33
  elif arg2 == "/":
 
 
34
  return arg1 / arg3
35
  else:
36
- raise ValueError("Invalid operator! Only '+', '-' , '*' and '/' are allowed.")
 
37
 
38
 
39
  @tool
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
  def calculator(arg1: int, arg2: str, arg3: int) -> int:
13
+ """
14
+ Performs basic arithmetic operations (addition, subtraction, multiplication, and division).
15
 
16
  Args:
17
+ arg1 (int): The first operand.
18
+ arg2 (str): The operator ('+', '-', '*', '/').
19
+ arg3 (int): The second operand.
20
 
21
  Returns:
22
  int: The result of the calculation.
23
 
24
  Raises:
25
  ValueError: If an invalid operator is provided.
26
+ """
27
  if arg2 == "+":
28
  return arg1 + arg3
29
  elif arg2 == "-":
 
31
  elif arg2 == "*":
32
  return arg1 * arg3
33
  elif arg2 == "/":
34
+ if arg3 == 0:
35
+ raise ValueError("Division by zero is not allowed.")
36
  return arg1 / arg3
37
  else:
38
+ raise ValueError("Invalid operator! Only '+', '-', '*', and '/' are allowed.")
39
+
40
 
41
 
42
  @tool