The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Make bs4 a local import in recursive_url_loader.py (#6693)
Lance Martindd36adc0f4cd
diff --git a/langchain/document_loaders/recursive_url_loader.py b/langchain/document_loaders/recursive_url_loader.pyindex 8ff452bf6d..7107f3a734 100644--- a/langchain/document_loaders/recursive_url_loader.py+++ b/langchain/document_loaders/recursive_url_loader.py@@ -2,7 +2,6 @@ from typing import Iterator, List, Optional, Setfrom urllib.parse import urlparseimport requests-from bs4 import BeautifulSoupfrom langchain.docstore.document import Documentfrom langchain.document_loaders.base import BaseLoader@@ -21,6 +20,13 @@ class RecusiveUrlLoader(BaseLoader):) -> Set[str]:"""Recursively get all child links starting with the path of the input URL."""+ try:+ from bs4 import BeautifulSoup+ except ImportError:+ raise ImportError(+ "The BeautifulSoup package is required for the RecusiveUrlLoader."+ )+# Construct the base and parent URLsparsed_url = urlparse(url)base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"