Baldros commited on
Commit
c8e174e
·
verified ·
1 Parent(s): 7bfc262

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -9,14 +9,28 @@ 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:
@@ -56,7 +70,8 @@ with open("prompts.yaml", 'r') as stream:
56
 
57
  agent = CodeAgent(
58
  model=model,
59
- tools=[final_answer, image_generation_tool,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
 
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def math_operation(arg1: float, arg2: float, operation: str) -> float:
13
+ """A tool that performs basic arithmetic operations.
14
+
15
  Args:
16
+ arg1: The first number.
17
+ arg2: The second number.
18
+ operation: The operation to perform ('add', 'subtract', 'multiply', 'divide').
19
+
20
+ Returns:
21
+ The result of the operation.
22
  """
23
+ match operation:
24
+ case "add":
25
+ return arg1 + arg2
26
+ case "subtract":
27
+ return arg1 - arg2
28
+ case "multiply":
29
+ return arg1 * arg2
30
+ case "divide":
31
+ return arg1 / arg2 if arg2 != 0 else float("inf") # Evita divisão por zero
32
+ case _:
33
+ raise ValueError("Invalid operation. Use 'add', 'subtract', 'multiply', or 'divide'.")
34
 
35
  @tool
36
  def get_current_time_in_timezone(timezone: str) -> str:
 
70
 
71
  agent = CodeAgent(
72
  model=model,
73
+ tools=[final_answer, image_generation_tool,
74
+ get_current_time_in_timezone,math_operation], ## add your tools here (don't remove final answer)
75
  max_steps=6,
76
  verbosity_level=1,
77
  grammar=None,