Spaces:
Sleeping
Sleeping
added a simple Tool called get_kcal_for_crisps_flavour
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 |
-
|
17 |
-
arg2: the second argument
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer, get_current_time_in_timezone, image_generation_tool], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def get_kcal_for_crisps_flavour(flavour:str)-> 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 gives back the kcal for a particular flavour of crisps
|
15 |
Args:
|
16 |
+
flavour: A string representing the flavour of the crisps (e.g., "Paprika")
|
|
|
17 |
"""
|
18 |
+
try:
|
19 |
+
match flavour:
|
20 |
+
case "Paprika":
|
21 |
+
return: "530 kcal"
|
22 |
+
case "Salt":
|
23 |
+
return: "521 kcal"
|
24 |
+
case _:
|
25 |
+
return: "not in my database"
|
26 |
+
except Exception as e:
|
27 |
+
return f"Error fetching time kcal for flavour '{flavour}': {str(e)}"
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
|
32 |
@tool
|
33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
66 |
|
67 |
agent = CodeAgent(
|
68 |
model=model,
|
69 |
+
tools=[final_answer, get_current_time_in_timezone, image_generation_tool, get_kcal_for_crisps_flavour], ## add your tools here (don't remove final answer)
|
70 |
max_steps=6,
|
71 |
verbosity_level=1,
|
72 |
grammar=None,
|