Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,25 +9,26 @@ from Gradio_UI import GradioUI
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
-
def buscar_datos_gob(term: str, page_size: int
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
Args:
|
17 |
-
term
|
18 |
-
page_size
|
19 |
-
page
|
20 |
-
sort
|
21 |
|
22 |
Returns:
|
23 |
-
|
24 |
"""
|
25 |
base_url = "https://datos.gob.es/apidata/catalog/dataset"
|
26 |
params = {
|
27 |
"q": term,
|
28 |
"_pageSize": page_size,
|
29 |
"_page": page,
|
30 |
-
"_sort": sort
|
31 |
}
|
32 |
headers = {
|
33 |
"Accept": "application/json"
|
@@ -38,7 +39,8 @@ def buscar_datos_gob(term: str, page_size: int = 10, page: int = 0, sort: str =
|
|
38 |
response.raise_for_status()
|
39 |
return response.json()
|
40 |
except requests.exceptions.RequestException as e:
|
41 |
-
return {"error": f"Error
|
|
|
42 |
|
43 |
@tool
|
44 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def buscar_datos_gob(term: str, page_size: int, page: int, sort: str) -> dict:
|
13 |
+
# It's important to specify the return type
|
14 |
+
# Keep this format for the description / args description but feel free to modify the tool
|
15 |
+
"""A tool that searches for datasets in the API of datos.gob.es.
|
16 |
|
17 |
Args:
|
18 |
+
term: The search term to filter the datasets.
|
19 |
+
page_size: The number of results per page (maximum: 50).
|
20 |
+
page: The page number for pagination of results.
|
21 |
+
sort: The field by which to sort the results (default: "title").
|
22 |
|
23 |
Returns:
|
24 |
+
A dictionary containing the search results from datos.gob.es API.
|
25 |
"""
|
26 |
base_url = "https://datos.gob.es/apidata/catalog/dataset"
|
27 |
params = {
|
28 |
"q": term,
|
29 |
"_pageSize": page_size,
|
30 |
"_page": page,
|
31 |
+
"_sort": sort
|
32 |
}
|
33 |
headers = {
|
34 |
"Accept": "application/json"
|
|
|
39 |
response.raise_for_status()
|
40 |
return response.json()
|
41 |
except requests.exceptions.RequestException as e:
|
42 |
+
return {"error": f"Error in the request: {str(e)}"}
|
43 |
+
|
44 |
|
45 |
@tool
|
46 |
def get_current_time_in_timezone(timezone: str) -> str:
|