Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
-
def grocery_info(version=1, grocery_id:
|
| 23 |
"""A tool that fetches the grocery information from the Swedish Food Agency api
|
| 24 |
Args:
|
| 25 |
version: version of tool argument.
|
|
@@ -39,12 +39,23 @@ def grocery_info(version=1, grocery_id: int, sprak=2):
|
|
| 39 |
|
| 40 |
if response.status_code == 200:
|
| 41 |
data = response.json()
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
else:
|
| 44 |
return "Error: Unable to find grocery data."
|
| 45 |
|
| 46 |
@tool
|
| 47 |
-
def ingredients(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
ingredient_api_url = f"{base_url}{ingred_url}"
|
| 49 |
|
| 50 |
response=requests.get(ingredient_api_url)
|
|
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
+
def grocery_info(version=1, grocery_id:int, sprak=2):
|
| 23 |
"""A tool that fetches the grocery information from the Swedish Food Agency api
|
| 24 |
Args:
|
| 25 |
version: version of tool argument.
|
|
|
|
| 39 |
|
| 40 |
if response.status_code == 200:
|
| 41 |
data = response.json()
|
| 42 |
+
grocery_description = data.get("namn")
|
| 43 |
+
grocery_ingredients = data.get("links")[2]['href']
|
| 44 |
+
return grocery_description, grocery_ingredients_link
|
| 45 |
else:
|
| 46 |
return "Error: Unable to find grocery data."
|
| 47 |
|
| 48 |
@tool
|
| 49 |
+
def ingredients(link = grocery_ingredients_link):
|
| 50 |
+
"""A tool that fetches the the ingredient of a grocery, based on the url
|
| 51 |
+
based on the grocery_ingredients_link output from the grocery_info function
|
| 52 |
+
Args:
|
| 53 |
+
url which is specific to get the grocery ingredients
|
| 54 |
+
|
| 55 |
+
Output:
|
| 56 |
+
a text string containing the ingredients
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
ingredient_api_url = f"{base_url}{ingred_url}"
|
| 60 |
|
| 61 |
response=requests.get(ingredient_api_url)
|