Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
add lazy import for langchain in pdfreader
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeknnDestroy committed Nov 29, 2023
1 parent 161b783 commit e9334b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion autollm/utils/pdf_reader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import List

from langchain.document_loaders import PDFMinerLoader
from llama_index.readers.base import BaseReader
from llama_index.schema import Document

Expand All @@ -16,6 +15,8 @@ def __init__(self, extract_images: bool = False) -> None:

def load_data(self, file_path: str, extra_info: dict = None) -> List[Document]:
"""Load data from a PDF file using langchain's PDFMinerLoader."""
from langchain.document_loaders import PDFMinerLoader

# Convert the PosixPath object to a string before passing it to PDFMinerLoader
loader = PDFMinerLoader(str(file_path), extract_images=self.extract_images)

Expand Down

0 comments on commit e9334b1

Please sign in to comment.