rchan26 commited on
Commit
d9cbbf7
·
verified ·
1 Parent(s): 8680107

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -9,22 +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 calculator(x: int | float, y: int | float, operation: str)-> int | float: #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 performs an operation between x and y.
15
  Args:
16
- x: first integer or float in the calculation
17
- y: second integer or float in the calculation
18
- operation: one of ["+", "-", "*", "/"]
19
  """
20
  if operation == "+":
21
- return x + y
22
  elif operation == "-":
23
- return x - y
24
  elif operation == "*":
25
- return x * y
26
  elif operation == "/":
27
- return x / y
28
  else:
29
  raise ValueError("operation must be one of ['+', '-', '*', '/']")
30
 
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def calculator(x: int | float, y: int | float, operation: str)-> str:
 
13
  """A tool that performs an operation between x and y.
14
  Args:
15
+ x: first integer or float in the calculation.
16
+ y: second integer or float in the calculation.
17
+ operation: one of ["+", "-", "*", "/"].
18
  """
19
  if operation == "+":
20
+ return str(f"{x}+{y} = {x+y}")
21
  elif operation == "-":
22
+ return str(f"{x}-{y} = {x-y}")
23
  elif operation == "*":
24
+ return str(f"{x}*{y} = {x*y}")
25
  elif operation == "/":
26
+ return str(f"{x}/{y} = {x/y}")
27
  else:
28
  raise ValueError("operation must be one of ['+', '-', '*', '/']")
29