Ferocious0xide commited on
Commit
02b4a70
·
verified ·
1 Parent(s): b50c4f3

Update tools/book_tool.py

Browse files
Files changed (1) hide show
  1. tools/book_tool.py +5 -5
tools/book_tool.py CHANGED
@@ -1,14 +1,14 @@
1
  from typing import List, Dict
2
  import requests
3
- from smolagents import Tool
4
 
5
  class BookSearchTool(Tool):
6
  name = "search_books"
7
  description = "Search for books using the Open Library API"
8
- input_types = {"query": str}
9
  output_type = List[Dict]
10
 
11
- def __call__(self, query: str) -> List[Dict]:
12
  try:
13
  url = f"https://openlibrary.org/search.json?q={query}&limit=5"
14
  response = requests.get(url)
@@ -32,10 +32,10 @@ class BookSearchTool(Tool):
32
  class BookDetailsTool(Tool):
33
  name = "get_book_details"
34
  description = "Get detailed information about a specific book from Open Library"
35
- input_types = {"book_key": str}
36
  output_type = Dict
37
 
38
- def __call__(self, book_key: str) -> Dict:
39
  try:
40
  url = f"https://openlibrary.org{book_key}.json"
41
  response = requests.get(url)
 
1
  from typing import List, Dict
2
  import requests
3
+ from smolagents.tools import Tool
4
 
5
  class BookSearchTool(Tool):
6
  name = "search_books"
7
  description = "Search for books using the Open Library API"
8
+ inputs = {'query': {'type': 'string', 'description': 'The search query to find books.'}}
9
  output_type = List[Dict]
10
 
11
+ def forward(self, query: str) -> List[Dict]:
12
  try:
13
  url = f"https://openlibrary.org/search.json?q={query}&limit=5"
14
  response = requests.get(url)
 
32
  class BookDetailsTool(Tool):
33
  name = "get_book_details"
34
  description = "Get detailed information about a specific book from Open Library"
35
+ inputs = {'book_key': {'type': 'string', 'description': 'The Open Library key for the book.'}}
36
  output_type = Dict
37
 
38
+ def forward(self, book_key: str) -> Dict:
39
  try:
40
  url = f"https://openlibrary.org{book_key}.json"
41
  response = requests.get(url)