helgn commited on
Commit
92e7fa0
·
verified ·
1 Parent(s): f0bdae7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
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
- if response.status_code == 200:
 
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
- else:
55
- print(f"Failed to retrieve data: {response.status_code}")
56
- return None
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: