Ajeya95 commited on
Commit
3bc4b87
·
verified ·
1 Parent(s): e86ed47

made changes in the animewatcher function so that it returns the list but not the string

Browse files
Files changed (1) hide show
  1. app.py +9 -2
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
- # Check if results is a string, meaning there may be an error or no results
 
 
23
  if isinstance(results, str):
24
- return f"Error: The search returned a string instead of a list. Received: {results}"
 
 
 
 
 
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!"