huggingsamurai commited on
Commit
74b3fc4
·
verified ·
1 Parent(s): 80e1bb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -31,23 +31,23 @@ def my_custom_tool(arg1:str)-> list[str]: #it's import to specify the return typ
31
 
32
  try:
33
  response = requests.get(url, headers=headers)
34
- response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
35
- soup = BeautifulSoup(response.content, "html.parser")
36
- results = soup.find_all("li", class_="booklink")
37
- urls = []
38
- for result in results[:10]: # grabs the top 10
39
- link = result.find("a", class_="link")
40
- if link:
41
- full_url = "https://www.gutenberg.org" + link["href"]
42
- urls.append(full_url)
43
- return urls
44
 
45
  except requests.exceptions.RequestException as e:
46
- print(f"Error: {e}")
47
- return None
48
  except Exception as e:
49
- print(f"An unexpected error occurred: {e}")
50
- return None
51
 
52
 
53
  @tool
 
31
 
32
  try:
33
  response = requests.get(url, headers=headers)
34
+ response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
35
+ soup = BeautifulSoup(response.content, "html.parser")
36
+ results = soup.find_all("li", class_="booklink")
37
+ urls = []
38
+ for result in results[:10]: # grabs the top 10
39
+ link = result.find("a", class_="link")
40
+ if link:
41
+ full_url = "https://www.gutenberg.org" + link["href"]
42
+ urls.append(full_url)
43
+ return urls
44
 
45
  except requests.exceptions.RequestException as e:
46
+ print(f"Error: {e}")
47
+ return None
48
  except Exception as e:
49
+ print(f"An unexpected error occurred: {e}")
50
+ return None
51
 
52
 
53
  @tool