Spaces:
Sleeping
Sleeping
add my_food_tool * update app.py
Browse files
app.py
CHANGED
@@ -58,6 +58,25 @@ def food_tool()-> str:
|
|
58 |
A tool that answer any question you have about food
|
59 |
"""
|
60 |
return "Wow~what a magic food!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
@tool
|
63 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
58 |
A tool that answer any question you have about food
|
59 |
"""
|
60 |
return "Wow~what a magic food!"
|
61 |
+
|
62 |
+
@tool
|
63 |
+
def my_food_tool(question: str) -> str:
|
64 |
+
"""A tool that responds to any food-related question with a magical phrase.
|
65 |
+
|
66 |
+
Args:
|
67 |
+
question: The user's question about food.
|
68 |
+
|
69 |
+
Returns:
|
70 |
+
A fixed magical response if the question is related to food.
|
71 |
+
"""
|
72 |
+
|
73 |
+
food_keywords = ["food", "eat", "drink", "meal", "dish", "snack", "recipe",
|
74 |
+
"cuisine", "restaurant", "fruit", "vegetable", "meat", "fish", "dessert"]
|
75 |
+
|
76 |
+
if any(keyword in question.lower() for keyword in food_keywords):
|
77 |
+
return "Wow~what a magic food!"
|
78 |
+
|
79 |
+
return "No food,No food!"
|
80 |
|
81 |
@tool
|
82 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|