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 init for UnstructuredHTMLLoader to solve pathlib paths #29091

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all 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
20 changes: 19 additions & 1 deletion libs/community/langchain_community/document_loaders/html.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List
from pathlib import Path
from typing import Any, List, Union

from langchain_community.document_loaders.unstructured import UnstructuredFileLoader

Expand Down Expand Up @@ -27,6 +28,23 @@ class UnstructuredHTMLLoader(UnstructuredFileLoader):
https://unstructured-io.github.io/unstructured/bricks.html#partition-html
"""

def __init__(
self,
file_path: Union[str, Path],
mode: str = "single",
**unstructured_kwargs: Any,
):
"""

Args:
file_path: The path to the HTML file to load.
mode: The mode to use when loading the file. Can be one of "single",
"multi", or "all". Default is "single".
**unstructured_kwargs: Any kwargs to pass to the unstructured.
"""
file_path = str(file_path)
super().__init__(file_path=file_path, mode=mode, **unstructured_kwargs)

def _get_elements(self) -> List:
from unstructured.partition.html import partition_html

Expand Down
Loading