Spaces:
Sleeping
Sleeping
bug fix for book search tool
Browse files- tools/book_search.py +3 -3
tools/book_search.py
CHANGED
|
@@ -33,7 +33,7 @@ class NYTBestSellerTool(Tool):
|
|
| 33 |
'genre':
|
| 34 |
{'type': 'string', 'description': 'The genre to search'},
|
| 35 |
'limit':
|
| 36 |
-
{'type': '
|
| 37 |
}
|
| 38 |
output_type = "string"
|
| 39 |
|
|
@@ -62,7 +62,7 @@ class NYTBestSellerTool(Tool):
|
|
| 62 |
"young-adult-paperback-monthly"
|
| 63 |
]
|
| 64 |
|
| 65 |
-
def forward(self, genre: str, limit:
|
| 66 |
if isinstance(limit,str):
|
| 67 |
limit = int(limit)
|
| 68 |
|
|
@@ -75,7 +75,7 @@ class NYTBestSellerTool(Tool):
|
|
| 75 |
f"https://api.nytimes.com/svc/books/v3/lists/{genre}.json",
|
| 76 |
params={"api-key":self.api_key}
|
| 77 |
)
|
| 78 |
-
if
|
| 79 |
raise Exception("Error getting the best seller list. Please try again later.")
|
| 80 |
|
| 81 |
book_results = result.json()['results']['books']
|
|
|
|
| 33 |
'genre':
|
| 34 |
{'type': 'string', 'description': 'The genre to search'},
|
| 35 |
'limit':
|
| 36 |
+
{'type': 'integer', 'description': 'The number of results to include', 'nullable': True}
|
| 37 |
}
|
| 38 |
output_type = "string"
|
| 39 |
|
|
|
|
| 62 |
"young-adult-paperback-monthly"
|
| 63 |
]
|
| 64 |
|
| 65 |
+
def forward(self, genre: str, limit: int = 5) -> str:
|
| 66 |
if isinstance(limit,str):
|
| 67 |
limit = int(limit)
|
| 68 |
|
|
|
|
| 75 |
f"https://api.nytimes.com/svc/books/v3/lists/{genre}.json",
|
| 76 |
params={"api-key":self.api_key}
|
| 77 |
)
|
| 78 |
+
if result.status_code != 200:
|
| 79 |
raise Exception("Error getting the best seller list. Please try again later.")
|
| 80 |
|
| 81 |
book_results = result.json()['results']['books']
|