Spaces:
Sleeping
Sleeping
made changes in the animewatcher function so that it returns the list but not the string
Browse files
app.py
CHANGED
@@ -19,9 +19,16 @@ def animewatcher(anime_name: str) -> str:
|
|
19 |
search_query = f"{anime_name} anime details"
|
20 |
results = duckduckgo_tool(search_query) # Fetch results from DuckDuckGo
|
21 |
|
22 |
-
#
|
|
|
|
|
23 |
if isinstance(results, str):
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
if not isinstance(results, list) or not results:
|
27 |
return f"No results found for '{anime_name}'. Maybe it's underrated!"
|
|
|
19 |
search_query = f"{anime_name} anime details"
|
20 |
results = duckduckgo_tool(search_query) # Fetch results from DuckDuckGo
|
21 |
|
22 |
+
# Debugging: Print output type
|
23 |
+
print(f"Debug: DuckDuckGo results -> {results} (Type: {type(results)})")
|
24 |
+
|
25 |
if isinstance(results, str):
|
26 |
+
# Try to parse JSON if possible (if the API returns a JSON string)
|
27 |
+
try:
|
28 |
+
import json
|
29 |
+
results = json.loads(results)
|
30 |
+
except json.JSONDecodeError:
|
31 |
+
return f"Error: Unexpected response format. Received: {results}"
|
32 |
|
33 |
if not isinstance(results, list) or not results:
|
34 |
return f"No results found for '{anime_name}'. Maybe it's underrated!"
|