Spaces:
Sleeping
Sleeping
cyberosa
commited on
Commit
·
f52ad11
1
Parent(s):
b3409ed
fixing type annotations
Browse files
tools/calories_checker.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import requests
|
2 |
import os
|
3 |
-
from typing import Any, Optional, List,
|
4 |
from smolagents.tools import Tool
|
5 |
|
6 |
|
@@ -19,7 +19,7 @@ class CaloriesCheckerTool(Tool):
|
|
19 |
self.is_initialized = False
|
20 |
self.api_key = os.environ.get("CALORIES_API_KEY", None)
|
21 |
|
22 |
-
def forward(self, query: str) ->
|
23 |
api_url = "https://api.api-ninjas.com/v1/nutrition?query={}".format(query)
|
24 |
response = requests.get(api_url, headers={"X-Api-Key": self.api_key})
|
25 |
if response.status_code == requests.codes.ok:
|
|
|
1 |
import requests
|
2 |
import os
|
3 |
+
from typing import Any, Optional, List, Dict
|
4 |
from smolagents.tools import Tool
|
5 |
|
6 |
|
|
|
19 |
self.is_initialized = False
|
20 |
self.api_key = os.environ.get("CALORIES_API_KEY", None)
|
21 |
|
22 |
+
def forward(self, query: str) -> list[dict[str, Any]]:
|
23 |
api_url = "https://api.api-ninjas.com/v1/nutrition?query={}".format(query)
|
24 |
response = requests.get(api_url, headers={"X-Api-Key": self.api_key})
|
25 |
if response.status_code == requests.codes.ok:
|