MathpixPDFLoader#
- class langchain_community.document_loaders.pdf.MathpixPDFLoader(
- file_path: str | PurePath,
- processed_file_format: str = 'md',
- max_wait_time_seconds: int = 500,
- should_clean_pdf: bool = False,
- extra_request_data: dict[str, Any] | None = None,
- **kwargs: Any,
Load PDF files using Mathpix service.
Initialize with a file path.
- Parameters:
file_path (str | PurePath) β a file for loading.
processed_file_format (str) β a format of the processed file. Default is βmdβ.
max_wait_time_seconds (int) β a maximum time to wait for the response from the server. Default is 500.
should_clean_pdf (bool) β a flag to clean the PDF file. Default is False.
extra_request_data (dict[str, Any] | None) β Additional request data.
**kwargs (Any) β additional keyword arguments.
Attributes
datasourceurlMethods
__init__(file_path[,Β processed_file_format,Β ...])Initialize with a file path.
A lazy loader for Documents.
aload()Load data into Document objects.
clean_pdf(contents)Clean the PDF file.
get_processed_pdf(pdf_id)A lazy loader for Documents.
load()Load data into Document objects.
load_and_split([text_splitter])Load Documents and split into chunks.
send_pdf()wait_for_processing(pdf_id)Wait for processing to complete.
- __init__(
- file_path: str | PurePath,
- processed_file_format: str = 'md',
- max_wait_time_seconds: int = 500,
- should_clean_pdf: bool = False,
- extra_request_data: dict[str, Any] | None = None,
- **kwargs: Any,
Initialize with a file path.
- Parameters:
file_path (str | PurePath) β a file for loading.
processed_file_format (str) β a format of the processed file. Default is βmdβ.
max_wait_time_seconds (int) β a maximum time to wait for the response from the server. Default is 500.
should_clean_pdf (bool) β a flag to clean the PDF file. Default is False.
extra_request_data (dict[str, Any] | None) β Additional request data.
**kwargs (Any) β additional keyword arguments.
- Return type:
None
- async alazy_load() AsyncIterator[Document]#
A lazy loader for Documents.
- Yields:
the documents.
- Return type:
AsyncIterator[Document]
- async aload() list[Document]#
Load data into Document objects.
- Returns:
the documents.
- Return type:
list[Document]
- clean_pdf(contents: str) str[source]#
Clean the PDF file.
- Parameters:
contents (str) β a PDF file contents.
- Return type:
str
Returns:
- lazy_load() Iterator[Document]#
A lazy loader for Documents.
- Yields:
the documents.
- Return type:
Iterator[Document]
- load() list[Document][source]#
Load data into Document objects.
- Returns:
the documents.
- Return type:
list[Document]
- load_and_split(
- text_splitter: TextSplitter | None = None,
Load Documents and split into chunks. Chunks are returned as Documents.
Do not override this method. It should be considered to be deprecated!
- Parameters:
text_splitter (Optional[TextSplitter]) β TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.
- Raises:
ImportError β If langchain-text-splitters is not installed and no text_splitter is provided.
- Returns:
List of Documents.
- Return type:
list[Document]
Examples using MathpixPDFLoader