cesarleoni commited on
Commit
475a39d
·
verified ·
1 Parent(s): 119adeb

chatgpt...

Browse files
Files changed (1) hide show
  1. app.py +27 -15
app.py CHANGED
@@ -4,6 +4,8 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
 
7
 
8
  from Gradio_UI import GradioUI
9
 
@@ -19,24 +21,34 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
19
  return "What magic will you build ?"
20
 
21
 
 
22
  @tool
23
- def calculus(arg1:chr, arg2:double, arg3: double)-> double:
24
- """A tool that does basic math operations, like adition, substraction, multimplication and division between two real numbers.
 
 
 
25
  Args:
26
- arg1: the operator (should be one of the following: '+','-','*','/')
27
- arg2: the first number
28
- arg3: the second number
 
 
 
29
  """
30
- if arg1=='+':
31
- return arg2+arg3
32
- elif arg1=='-':
33
- return arg2-arg3
34
- elif arg1=='*':
35
- return arg2*arg3
36
- elif arg1=='/':
37
- return arg2/arg3
38
-
39
- return "The character in arg1 wasn't a valid mathematical operation!"
 
 
 
40
 
41
  @tool
42
  def get_current_time_in_timezone(timezone: str) -> str:
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from typing import Union
8
+
9
 
10
  from Gradio_UI import GradioUI
11
 
 
21
  return "What magic will you build ?"
22
 
23
 
24
+
25
  @tool
26
+ def calculus(arg1: str, arg2: float, arg3: float) -> Union[float, str]:
27
+ """
28
+ A tool that does basic math operations: addition, subtraction,
29
+ multiplication, and division between two real numbers.
30
+
31
  Args:
32
+ arg1: The operator (should be one of the following: '+', '-', '*', '/')
33
+ arg2: The first number
34
+ arg3: The second number
35
+
36
+ Returns:
37
+ The result of the math operation, or an error message if invalid input.
38
  """
39
+ if arg1 == '+':
40
+ return arg2 + arg3
41
+ elif arg1 == '-':
42
+ return arg2 - arg3
43
+ elif arg1 == '*':
44
+ return arg2 * arg3
45
+ elif arg1 == '/':
46
+ if arg3 == 0:
47
+ return "Error: Division by zero!"
48
+ return arg2 / arg3
49
+
50
+ return "Error: Invalid operator. Use one of '+', '-', '*', '/'"
51
+
52
 
53
  @tool
54
  def get_current_time_in_timezone(timezone: str) -> str: