Spaces:
Sleeping
Sleeping
Commit
·
0e6c094
1
Parent(s):
65ffbae
add tools
Browse files
app.py
CHANGED
|
@@ -9,14 +9,25 @@ 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 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
arg1: the first
|
| 17 |
-
arg2: the second
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -56,7 +67,8 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
tools=[final_answer,
|
| 59 |
-
|
|
|
|
| 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 calculator(x:int, y:int, operator:str)-> int: #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 calculates math calculations bwteen two integers
|
| 15 |
Args:
|
| 16 |
+
arg1: the first int input
|
| 17 |
+
arg2: the second int input
|
| 18 |
+
arg3: the operator
|
| 19 |
"""
|
| 20 |
+
|
| 21 |
+
if operator == '+':
|
| 22 |
+
return x + y
|
| 23 |
+
elif operator == '-':
|
| 24 |
+
return x - y
|
| 25 |
+
elif operator == '*':
|
| 26 |
+
return x * y
|
| 27 |
+
elif operator == '/':
|
| 28 |
+
return x / y
|
| 29 |
+
else:
|
| 30 |
+
raise Exception(f"Invalid operator: {operator}")
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 67 |
agent = CodeAgent(
|
| 68 |
model=model,
|
| 69 |
tools=[final_answer,
|
| 70 |
+
calculator,
|
| 71 |
+
get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|