Minor fix: adding a 60 seconds timeout to the visit webpage tool (#308)
* adding a 60 seconds timeout * lowerting the timeout to 20s
This commit is contained in:
parent
43904f32c7
commit
5d6502ae1d
|
@ -225,8 +225,8 @@ class VisitWebpageTool(Tool):
|
||||||
"You must install packages `markdownify` and `requests` to run this tool: for instance run `pip install markdownify requests`."
|
"You must install packages `markdownify` and `requests` to run this tool: for instance run `pip install markdownify requests`."
|
||||||
) from e
|
) from e
|
||||||
try:
|
try:
|
||||||
# Send a GET request to the URL
|
# Send a GET request to the URL with a 20-second timeout
|
||||||
response = requests.get(url)
|
response = requests.get(url, timeout=20)
|
||||||
response.raise_for_status() # Raise an exception for bad status codes
|
response.raise_for_status() # Raise an exception for bad status codes
|
||||||
|
|
||||||
# Convert the HTML content to Markdown
|
# Convert the HTML content to Markdown
|
||||||
|
@ -237,6 +237,8 @@ class VisitWebpageTool(Tool):
|
||||||
|
|
||||||
return truncate_content(markdown_content, 10000)
|
return truncate_content(markdown_content, 10000)
|
||||||
|
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
return "The request timed out. Please try again later or check the URL."
|
||||||
except RequestException as e:
|
except RequestException as e:
|
||||||
return f"Error fetching the webpage: {str(e)}"
|
return f"Error fetching the webpage: {str(e)}"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue