Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,13 +79,19 @@ def restructure_europeana_response(europeana_json: dict) -> str:
|
|
| 79 |
########################################
|
| 80 |
# EUROPEANA TOOL
|
| 81 |
########################################
|
| 82 |
-
EUROPEANA_API_KEY = "vievinatme" #
|
| 83 |
|
| 84 |
@tool
|
| 85 |
def query_europeana(query: str) -> str:
|
| 86 |
"""
|
| 87 |
A tool that queries the Europeana Search API for a given query
|
| 88 |
and returns up to 5 results in a kid-friendly summary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
"""
|
| 90 |
endpoint = "https://api.europeana.eu/record/v2/search.json"
|
| 91 |
params = {
|
|
@@ -100,13 +106,11 @@ def query_europeana(query: str) -> str:
|
|
| 100 |
if response.status_code != 200:
|
| 101 |
return f"Oops, something went wrong: {data.get('error', 'Unknown HTTP error')}"
|
| 102 |
|
| 103 |
-
# Use our restructure function for a nice summary
|
| 104 |
return restructure_europeana_response(data)
|
| 105 |
|
| 106 |
except Exception as e:
|
| 107 |
return f"Error calling Europeana API: {str(e)}"
|
| 108 |
|
| 109 |
-
|
| 110 |
########################################
|
| 111 |
# TIME TOOL
|
| 112 |
########################################
|
|
|
|
| 79 |
########################################
|
| 80 |
# EUROPEANA TOOL
|
| 81 |
########################################
|
| 82 |
+
EUROPEANA_API_KEY = "vievinatme" #
|
| 83 |
|
| 84 |
@tool
|
| 85 |
def query_europeana(query: str) -> str:
|
| 86 |
"""
|
| 87 |
A tool that queries the Europeana Search API for a given query
|
| 88 |
and returns up to 5 results in a kid-friendly summary.
|
| 89 |
+
|
| 90 |
+
Args:
|
| 91 |
+
query: A string representing the search term (e.g. 'Van Gogh')
|
| 92 |
+
|
| 93 |
+
Returns:
|
| 94 |
+
A string summary describing up to 5 Europeana items in a child-friendly format.
|
| 95 |
"""
|
| 96 |
endpoint = "https://api.europeana.eu/record/v2/search.json"
|
| 97 |
params = {
|
|
|
|
| 106 |
if response.status_code != 200:
|
| 107 |
return f"Oops, something went wrong: {data.get('error', 'Unknown HTTP error')}"
|
| 108 |
|
|
|
|
| 109 |
return restructure_europeana_response(data)
|
| 110 |
|
| 111 |
except Exception as e:
|
| 112 |
return f"Error calling Europeana API: {str(e)}"
|
| 113 |
|
|
|
|
| 114 |
########################################
|
| 115 |
# TIME TOOL
|
| 116 |
########################################
|