Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,8 +40,9 @@ def get_calories(meal:str) -> Union[str, None]:
|
|
| 40 |
'json': 1
|
| 41 |
}
|
| 42 |
response = requests.get(search_url, params=params)
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 45 |
data = response.json()
|
| 46 |
if data['count'] > 0:
|
| 47 |
for product in data['products']:
|
|
@@ -51,9 +52,9 @@ def get_calories(meal:str) -> Union[str, None]:
|
|
| 51 |
return 'No data found'
|
| 52 |
else:
|
| 53 |
return 'No data found'
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
|
| 58 |
@tool
|
| 59 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 40 |
'json': 1
|
| 41 |
}
|
| 42 |
response = requests.get(search_url, params=params)
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
response.status_code == 200:
|
| 46 |
data = response.json()
|
| 47 |
if data['count'] > 0:
|
| 48 |
for product in data['products']:
|
|
|
|
| 52 |
return 'No data found'
|
| 53 |
else:
|
| 54 |
return 'No data found'
|
| 55 |
+
except Exception as e:
|
| 56 |
+
return (f"Failed to retrieve data: {response.status_code}")
|
| 57 |
+
|
| 58 |
|
| 59 |
@tool
|
| 60 |
def get_current_time_in_timezone(timezone: str) -> str:
|