Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community: add trust_env at web_base_loader #28514

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/docs/integrations/document_loaders/web_base.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
"source": [
"from langchain_community.document_loaders import WebBaseLoader\n",
"\n",
"loader = WebBaseLoader(\"https://www.espn.com/\")"
"loader = WebBaseLoader(\"https://www.espn.com/\")\n",
ccurme marked this conversation as resolved.
Show resolved Hide resolved
"# If you need to use the proxy to make web requests, for example using http_proxy/https_proxy environmental variables,\n",
"# please set trust_env=True explicitly here as follows:\n",
"# loader = WebBaseLoader(\"https://www.espn.com/\", trust_env=True)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(
session: Any = None,
*,
show_progress: bool = True,
trust_env: bool = False,
ccurme marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
"""Initialize loader.

Expand Down Expand Up @@ -189,6 +190,7 @@ def __init__(
self.continue_on_failure = continue_on_failure
self.autoset_encoding = autoset_encoding
self.encoding = encoding
self.trust_env = trust_env

@property
def web_path(self) -> str:
Expand All @@ -199,7 +201,7 @@ def web_path(self) -> str:
async def _fetch(
self, url: str, retries: int = 3, cooldown: int = 2, backoff: float = 1.5
) -> str:
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(trust_env=self.trust_env) as session:
for i in range(retries):
try:
kwargs: Dict = dict(
Expand Down
Loading