From 6b46b5e9ce6aa1bdc61a76e7778ec79afeb5691e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B9=BF=E9=B9=BF=E9=B9=BF=E9=B2=A8?= <1243101939@qq.com> Date: Wed, 19 Jun 2024 11:02:46 +0800 Subject: [PATCH] community: add **request_kwargs and expect TimeError AsyncHtmlLoader (#23068) - **Description:** add `**request_kwargs` and expect `TimeError` in `_fetch` function for AsyncHtmlLoader. This allows you to fill in the kwargs parameter when using the `load()` method of the `AsyncHtmlLoader` class. Co-authored-by: Yucolu --- .../langchain_community/document_loaders/async_html.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/document_loaders/async_html.py b/libs/community/langchain_community/document_loaders/async_html.py index 1bd40aff5e5..97039cffd72 100644 --- a/libs/community/langchain_community/document_loaders/async_html.py +++ b/libs/community/langchain_community/document_loaders/async_html.py @@ -137,6 +137,7 @@ class AsyncHtmlLoader(BaseLoader): url, headers=self.session.headers, ssl=None if self.session.verify else False, + **self.requests_kwargs, ) as response: try: text = await response.text() @@ -144,7 +145,7 @@ class AsyncHtmlLoader(BaseLoader): logger.error(f"Failed to decode content from {url}") text = "" return text - except aiohttp.ClientConnectionError as e: + except (aiohttp.ClientConnectionError, TimeoutError) as e: if i == retries - 1 and self.ignore_load_errors: logger.warning(f"Error fetching {url} after {retries} retries.") return ""