Matty-Sam commited on
Commit
1545cd3
·
verified ·
1 Parent(s): d6754ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -36,12 +36,18 @@ def get_current_time_in_timezone(timezone: str) -> str:
36
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
37
 
38
  @tool
39
- def search_for_books(search_term: str) -> str:
40
  """A tool that searches for books by author keywords or words in the title of the book
41
  Args:
42
- search_term: A string representing a search terms. Can be part of the book title or the author's name.
 
43
  """
 
 
 
 
44
  try:
 
45
  params = {"search": search_terms}
46
  base_url = 'https://gutendex.com/books'
47
  response = requests.get(base_url, params=params)
 
36
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
37
 
38
  @tool
39
+ def search_for_books(author: str = '', title: str = '') -> str:
40
  """A tool that searches for books by author keywords or words in the title of the book
41
  Args:
42
+ author: A string representing an authors name.
43
+ title: A string representing a book title.
44
  """
45
+
46
+ if not author and not title:
47
+ return 'Must provide at least one of author or title.'
48
+
49
  try:
50
+ search_terms = ' '.join(author, title)
51
  params = {"search": search_terms}
52
  base_url = 'https://gutendex.com/books'
53
  response = requests.get(base_url, params=params)