Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 13 |
-
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
arg1:
|
| 17 |
-
arg2:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,
|
|
|
|
| 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,
|